http://localhost:8080/user-authorization/users/ /* Don't */ http://localhost:8080/user-authorization/users /* Do */
2. Use hypens (-), use lowercase letters, do not use underscore (_), do not use file extension
http://localhost:8080/userAuthorization/homeButtons /* Don't */ http://localhost:8080/user_authorization/home_buttons /* Don't */ http://localhost:8080/USER-AUTHORIZATION/HOME_BUTTONS /* Don't */ http://localhost:8080/user-authorization/home-buttons.xml /* Don't. if you want to show media type, use Content-Type header */ http://localhost:8080/user-authorization/home-buttons /* Do */
3.If you have a hierarchical relation (like user's buttons, user's sidebar buttons) then divide this relation by using slash.
http://localhost:8080/users-buttons /* Don't */ http://localhost:8080/users-sidebar-buttons/{id} /* Don't */ http://localhost:8080/users/{id}/buttons /* Do */ http://localhost:8080/users/{id}/sidebar-buttons /* Do */
4. Example for returning collection or a singular object:
http://localhost:8080/user-authorization/cards /* Use this if you will return a collection of card */ http://localhost:8080/user-authorization/cards/{id} /* Use this if only the given card will return */
5. Do not use crud function names like get, delete, update, create.
HTTP request methods (GET, PUT, POST, DELETE) should indicate the type of the function.
/* Get given user's cards */ HTTP GET http://localhost:8080/users/{id}/cards /* Get given user's card for given id */ HTTP GET http://localhost:8080/users/{id}/cards/{id} /* create card for given user */ HTTP POST http://localhost:8080/users/{id}/cards /* Update card for given user */ HTTP PUT http://localhost:8080/users/{id}/cards/{id} /* Delete card for given user */ HTTP DELETE http://localhost:8080/users/{id}/cards/{id}
6. If you need parameters like sorting, filtering, limiting then use query parameters.
http://localhost:8080/users?sort=registration-date
No comments:
Post a Comment