old-backside-byu-project / backside-api

The HTTP API for backside
0 stars 0 forks source link

Can't write a plain value (not a tree) with HTTP API #7

Open trevordixon opened 10 years ago

trevordixon commented 10 years ago

Firebase allows plain values and arrays in addition to JSON objects. For example:

curl -X PUT -d '"hi"' https://ana-demo.firebaseio.com/test.json
curl -X PUT -d '5' https://ana-demo.firebaseio.com/test.json
curl -X PUT -d '[1,2,3]' https://ana-demo.firebaseio.com/test.json

We allow only JSON objects. We should support at least strings and numbers too.

trevordixon commented 10 years ago

Note that this does not work in Firebase:

curl -X PUT -d 'hi' https://ana-demo.firebaseio.com/test.json

It requires strings to be quoted. We may or may not want to emulate them in this regard.

addisonj commented 10 years ago

I have changes that allow it to work via a different mechanism.

It relies on the content-type being set: text/plain (or text/*) sets the key as a text field (number fields are a bit trickier...) application/json or urlencoded are treated as objects

I kind of like having it be explicit with the content-type header (what its for basically), instead of working with the string. But, firebase also makes it more "noob friendly".

Perhaps we can support both?

On Tue, Jun 17, 2014 at 11:09 AM, Trevor Dixon notifications@github.com wrote:

Note that this does not work in Firebase:

curl -X PUT -d 'hi' https://ana-demo.firebaseio.com/test.json

It requires strings to be quoted. We may or may not want to emulate them in this regard.

— Reply to this email directly or view it on GitHub https://github.com/backside/backside-api/issues/7#issuecomment-46336424.

trevordixon commented 10 years ago

That makes sense; I like it. Let's do it Firebase's way if there's no Content-Type header.

trevordixon commented 10 years ago

Firebase behaves exactly the same way as JSON.parse.