Skip to content

Instantly share code, notes, and snippets.

@karlseguin
Created November 10, 2011 12:03
Show Gist options
  • Save karlseguin/1354705 to your computer and use it in GitHub Desktop.
Save karlseguin/1354705 to your computer and use it in GitHub Desktop.
You build an endpoint that takes in data and saves it.
This is a service that takes in data from outside sources, the user can be any type.
(some sites use integers, some use strings, some guids...)
3 samples:
POST /notes
{
user: 9000
message: 'over'
}
POST /notes
{
user: 'vegeta'
message: 'over 9000!'
}
POST /notes
{
user: '9002'
message: 'blah'
}
Now we want to let people get the data:
GET /notes/9000
id = request[:id]
Right now, id is a string. But, if I use a string to look up, It won't return anything.
GET IS FAIL
@karlseguin
Copy link
Author

I'll give you an example of where this is common.

When you display disqus on your page, you specify a "disqus_identifier". This can be anything. For example all my old post use an integer, which is the id of the row in the database. All my new post use the url (a string), since I moved to github+jekyll.

Once you start talking about publicly accessible services, I think this becomes a lot more common.

(My guess is that disqus just converts everything to a string...which is pragmatic, but it makes me want to RAGE QUIT)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment