理解 restful

Ivony:用 URL 定位资源,用 HTTP 描述操作。

徐磊:看 url 就知道要什么,看 http method 就知道干什么,看 http status code 就知道结果如何。

覃超:URI 使用名词而不是动词,且推荐用复数。

BAD

  • /getProducts
  • /listOrders
  • /retrieveClientByOrder?orderld=1

GOOD

  • GET /products: will return the list of all products
  • POST /products: will add a product to the collection
  • GET /products/4: will retrieve product #4
  • PATCH/PUT /products/4 will update product #4