Designing of Restful-URI
Want to share a good article about REST-URI design which may be useful for those who new in REST.
http://blog.2partsmagic.com/restful-uri-design/
In short, author points to:
http://blog.2partsmagic.com/restful-uri-design/
In short, author points to:
- URI should be human readable and easily guessed.
- Each part should be meaningful. All URI parts together should be good nested, and help visualize the site structure.
- http://example.com/cars/alfa-romeos/gt
- Nouns, not verbs.
- Resource Names: prefer to use lower-case and hyphen instead of spaces.
- http://example.com/tasks/by-a-new-car
- Resource IDs: prefer to use additional meaning prefix.
- http://example.com/tasks/task-17
- http://example.com/conversations/conversation-{id}/todo-list-{id}/todo-{id}
- Query args should used for querying/searching resources (exclusively).
- http://example.com/tasks?created=2009-04-26&group=major
- No special chars or file extensions (.php, .aspx) if they are not meaningful.
- Permanent. Should not be changed with time.
- Context friendly.
- http://example.com/users/current/details vs. http://example.com/users/user-anton/details
- http://example.com/forecasts/cambridge/today may redirects to, say, http://example.com/forecasts/cambridge/2009-04-26
Comments
Post a Comment