[Gllug] REST example

Dean Wilson dwilson at unixdaemon.net
Sat Nov 12 19:19:58 UTC 2005


On Sat, Nov 12, 2005 at 05:55:20PM +0000, Tristan Hill wrote:
> Can anyone think of an example for the REST compatible way to deal with
> an increasing or decreasing count.

POST and DELETE are your friends. Maybe PUT but POST seems to make more
sense as it's often treated as APPEND in web services.

> how is that achieved since it changes the server state? 

As a rule GETs should be repeatable and not have side effects.

> I thought the client could PUT a copy of the data received previously
> with a lower quantity, but didn't think that would be very robust with
> multiple clients.

It's the same with which ever verb you use. If you're worried about
concurrent access then look at your back end, it should be the same as
adding a new value in a web app, you tell the back end and it worries about
atomic increments.

If your application is going to decrement in steps then DELETE the value
it's dropped by. If you're replacing one absolute value for another then...
not sure :) I'd say DELETE and PUT (not POST as it's a new number but this
will cause concurrency issues).

> What about a url to return a unique (increasing) number each time it is
> accessed - could that be RESTful?

If you've got the time have a read through this:
http://www.xml.com/lpt/a/2005/01/05/restful.html

It's a good example of a RESTian approach and it's not too abstract (or
long!)

HTH

  Dean
-- 
Dean Wilson             http://www.unixdaemon.net
Profanity is the one language all programmers understand
  --- Anon
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list