商城体系RESTful API设想

接口设想

我以为一个好的接口,就算是零丁掏出个中一个来看,也能邃晓它的用处

通用接口

POST    /api/v1/tokens/
DELETE  /api/v1/tokens/:id/
GET     /api/v1/search/

客人形式接口

POST    /api/v1/users/
GET     /api/v1/guest/goods/
GET     /api/v1/guest/goods/:id/
GET     /api/v1/guest/goods/:id/comments/
GET     /api/v1/guest/goods/:id/comments/:id/

用户形式接口

GET     /api/v1/users/me/
PATCH   /api/v1/users/me/
PUT     /api/v1/users/me/password/
GET     /api/v1/user/goods/
GET     /api/v1/user/goods/:id/
GET     /api/v1/user/goods/:id/comments/
GET     /api/v1/user/goods/:id/comments/:id/
POST    /api/v1/user/orders/
GET     /api/v1/user/orders/
GET     /api/v1/user/orders/:id/
POST    /api/v1/shopping_cart/goods/
GET     /api/v1/shopping_cart/goods/
DELETE  /api/v1/shopping_cart/goods/:id/
PATCH   /api/v1/shopping_cart/goods/:id/

背景形式接口

GET     /api/v1/admin/users/
GET     /api/v1/admin/users/:id/
PATCH   /api/v1/admin/users/:id/
GET     /api/v1/admin/users/me/
PATCH   /api/v1/admin/users/me/
PUT     /api/v1/admin/users/me/password/
GET     /api/v1/admin/goods/
GET     /api/v1/admin/goods/:id/
POST    /api/v1/admin/goods/
PUT     /api/v1/admin/goods/:id/
PATCH   /api/v1/admin/goods/:id/
DELETE  /api/v1/admin/goods/:id/
GET     /api/v1/admin/orders/
GET     /api/v1/admin/orders/:id/
    原文作者:Prasanta
    原文地址: https://segmentfault.com/a/1190000008541074
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞