Skip to content

Instantly share code, notes, and snippets.

@cesarmarinhorj
Forked from alexpchin/restful_routes.md
Last active July 29, 2024 21:47
Show Gist options
  • Save cesarmarinhorj/3630f8d30bf0bf10ae0325bc20d28099 to your computer and use it in GitHub Desktop.
Save cesarmarinhorj/3630f8d30bf0bf10ae0325bc20d28099 to your computer and use it in GitHub Desktop.
7 Restful Routes

Updated to more pactical routes.

Resource always in singular. Plural is irregular, impure.

Initial route actions. More is Business dependent.

Update can use all three verbs, depends of client behavior.

Auth and permissions not minded here.

URL HTTP Verb Action Standard?
/resource GET index Y
/resource/count GET count N
/resource/list GET list N
/resource/new GET getCreateForm N
/resource POST create Y
/resource/:id GET getById Y
/resource/:id/edit GET getEditForm N
/resource/:id PATCH/POST/PUT edit Y
/resource/:id DELETE delete Y
/resource/find GET getFindForm N
/resource/find POST find N

Rails routes

Verb   URI Pattern                   Controller#Action
GET    /resource(.:format)            resource#index
POST   /resource(.:format)            resource#create
GET    /resource/:id(.:format)        resource#show
PATCH  /resource/:id(.:format)        resource#update
PUT    /resource/:id(.:format)        resource#update
DELETE /resource/:id(.:format)        resource#destroy

Crow Status Codes

Code Description
100 Continue
101 Switching Protocols
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
307 Temporary Redirect
308 Permanent Redirect
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
409 Conflict
410 Gone
413 Payload Too Large
415 Unsupported Media Type
416 Range Not Satisfiable
417 Expectation Failed
428 Precondition Required
429 Too Many Requests
451 Unavailable For Legal Reasons
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
506 Variant Also Negotiates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment