Resources, not Objects
Keyur, you must think in terms of resources, not object methods. Nouns, not verbs. In a restful architecture you don't cause your person to talk, you listen to the person's words:
GET /persons/1
or, if you want to be fancy:
GET /persons/1/words
Likewise, you don't cause them to walk a step, you update the person with a new location:
PUT /persons/1 { ..., "location": [[-100.0, 40.0]] }
or:
PUT /persons/1/location { "location": [[-100.0, 40.0]] }
Matrix URIs? They're standard with Rails, but mainly to allow PUT operations to tunnel via POST from dumb clients like the browser:
POST /persons/1;edit { ..., "location": [[-100.0, 40.0]] }
Comments
Re: Resources, not Objects
Author: Christopher Schmidt
Ah, good, I knew something seem wrong, but I couldn't figure out what it was. Don't forget how to delete people! DELETE /persons/42Re: Resources, not Objects
Author: Sean
Person 42, please report immediately to the disintegration chamber. Thank you.But everything may not be model-able as a resource...
Author: Keyur
Sean - first of all, thanks for the feedback. I am with you in that one should always think resources first when designing a REST API. But there are cases where you can't model everything as a resource - and not all reasons are technical in nature. For ex. your users are used to a certain vocabulary and if you define new terms it's that much more to educate them and something which might actually go against the grain of your system. Basically, I too would like to model everything as a resource first. But in situations where I have to introduce a verb, I'll have to go with one of the 3 approaches(or others if there are any) that I listed.Re: Resources, not Objects
Author: Sean
I agree that there may be cases that can't be modeled restfully, but your Persons example is not one of them. What are the limits of REST? Are GIS systems more or less naturally restful? More, in my assessment, and I'll point to ArcSDE, PostGIS, and WxS as evidence. Each reduce GIS tasks to CRUD operations and, like you said, these map readily to REST. Still, REST is no silver bullet, and it would be good to identify classes of systems that don't benefit from restful architecture.