Answers
比利丶海灵顿
answered 10 years, 1 month ago
Laplace
answered 10 years, 1 month ago
设计方法有很多种,借用Backbone.js 的说法: There's More Than One Way To Do It ,不要太纠结。
简单的说,下面几种都不错:
-
GET /ec2/instance/batch?id=aa,bb,cc
:简约的设计 -
GET /ec2/instance?batch={"ids":["aa","bb","cc"]}
:健壮的设计 -
GET /ec2/instance?batch=[{"method":"DELETE","id":"aa"},{"method":"DELETE","id":"bb"},{"method":"DELETE","id":"cc"}]
: facebook 的设计 (墙外)
把上面的
GET
都改成
POST
也没什么问题。
设计 batch 的时候就不用太纠结于 RESTful 的定义(至少我是这样觉得),毕竟是为了优化性能而存在的东西。
actfate
answered 10 years, 1 month ago