node.js - some more help for naming conventions plural vs singular -
there answers out there question different i'm trying find out uri when i've detail on product or when i've return detail on product plus it's customers. need standard solution following 4 api calls. need standard naming convention particular situation, please fix them following.
plural (with s)
get /products
- list products
get /products/1
- detail of product (no customers)
singular
get /product/1
- detail of product plus it's customers
get /product/1/customers
customers of product 1
from above i'm trying find solution these two.
get /products/1
- detail of product (no customers)
get /product/1
- detail of product plus it's customers
no, don't use differen urls differentiate between product , without customers. use content negotioation.
to product with embedded customers, use 1 accept
header:
get /products/1 accept: application/vnd.com.example.rest.customer.long+json
to product without customers, use different accept
header.
get /products/1 accept: application/vnd.com.example.rest.customer.short+json
but use the same url since requeting the same resource. request diferent representations of url, use content negotiation.
Comments
Post a Comment