Sunday, February 5, 2012

Feeling like I'm PWNing REST

I'm working hard to make the private API I'm implementing at my current job a RESTful
uri scheme, and I feel like I hit a point of transcendence recently when I decided how to record a user
staring a story.

  • PUT /article/:articleID/favorite/:userID

  • DELETE /article/:articleID/favorite/:userID

I decided
that POST didn't make sense, as you couldn't really favorite a story more than once at
a time, and of course DELETE makes sense here.  Adding them as a relation between the article and the user
seems to make sense in this URI scheme as well.

So, all in all, I'm proud of myself.
 Despite it being such a tiny, simplistic thing.

1 comment:

  1. I hear ya. I came across a similar situation while I was writing my own REST API (in
    Python) for a Google App Engine Datastore.

    I'm planning to eventually build
    it out into a complete inventory tracking system. At one point I was trying to figure out how to update/add
    multiple items at once when I finally realized what the differences between POST and PUT just sort of

    It's amazing how under-appreciated REST is out in the working
    world. If you're interested in reading more about it I suggest you take a look at It's a timeless gem that I stumbled on in the 'popular'
    section of Pinboard.