lib/rest-firebase.rb in rest-firebase-0.9.0 vs lib/rest-firebase.rb in rest-firebase-0.9.1

- old
+ new

@@ -5,11 +5,12 @@ # https://www.firebase.com/docs/rest-api.html RestFirebase = RC::Builder.client(:d, :secret, :auth) do use RC::Timeout , 10 use RC::DefaultSite , 'https://SampleChat.firebaseIO-demo.com/' - use RC::DefaultHeaders, {'Accept' => 'application/json'} + use RC::DefaultHeaders, {'Accept' => 'application/json', + 'Content-Type' => 'application/json'} use RC::DefaultQuery , nil use RC::FollowRedirect, 1 use RC::CommonLogger , nil use RC::Cache , nil, 600 do @@ -72,12 +73,17 @@ end end end def request env, app=app - super(env.merge(REQUEST_PATH => "#{env[REQUEST_PATH]}.json", - REQUEST_PAYLOAD => Json.encode(env[REQUEST_PAYLOAD])), - app) + path = "#{env[REQUEST_PATH]}.json" + payload = if env[REQUEST_PAYLOAD] + {REQUEST_PAYLOAD => Json.encode(env[REQUEST_PAYLOAD])} + else + {} + end + + super(env.merge(REQUEST_PATH => path).merge(payload), app) end def generate_auth opts={} raise RestFirebase::Error::ClientError.new( "Please set your secret") unless secret