@bergus
2016-12-23T14:34:24.000000Z
字数 961
阅读 1488
restful
API设计
# 批量执行动作
POST /api/users/actions -d {ids:[id1,id2,...],actions:["touch","rm","ls"]}
# 对特定资源执行批量动作
POST /api/users/{id1}/actions -d [{"actions":["touch","rm","ls"]}]
# 对特定资源执行特定动作
POST /api/users/{id1}/{action}
# 创建资源
POST /api/users -d [{"user_name":123},{"user_name":1}]
# 批量删除数据
DELETE /api/users -d {ids:[id1,id2,...],fields:[field1,field2,...],where:{field1:{">":1,"<":4}}}
# 删除特定资源
DELETE /api/users/{id1} -d {fields:[field1,field2,...],where:{field1:{">":1,"<":4}}},
PUT /api/users -d {ids:[id1,id2,...],fields:{field1:value1,field2:value2},where:{field1:{">":1,"<":4}}}
PUT /api/users/{id1} -d {fields:{field1:value1,field2:value2},where:{field1:{">":1,"<":4}}}
GET /api/users?ids=id1,id2,id3&fields=user_name,passwd&conds=1<user_name<4&page=1&per_page=50}
GET /api/users -d {ids:[id1,id2,...],fields:["user_name","passwd"],where:{field1:{">":1,"<":4}},"page":1,"per_page":50}
GET /api/users/{id1} -d {fields:["user_name","passwd"]}