使用RESTful端点获取多个资源的更好方法是什么?

时间:2012-11-21 19:43:08

标签: rest

您好我正在尝试设计一个可以使用Squid缓存获益的RESTful端点。我有两种方法来设计这个REST,但我不确定哪种方法更好。第一个获取学生ID列表,您需要执行单个提取以获取单个记录。第二个获取所有记录并具有分页。第二个也有奇异的资源获取功能。

谢谢,

获得课堂/ {classroomId} /学生

回应:

[1,2,3,4,5,6,7]

获取课堂/ {classroomId} / students / 1

回应:

{"studentId":1,"firstname","abc","lastname":"def"}

获得课堂/ {classroomId} /学生

回应:

{
items:[
{{"studentId":1,"firstname","abc","lastname":"def"},
{"studentId":2,"firstname","abc","lastname":"def"},
{"studentId":3,"firstname","abc","lastname":"def"},
{"studentId":4,"firstname","abc","lastname":"def"}}]
startIndex:0,
limit:4
}

获取课堂/ {classroomId} / students / 1

回应:

{"studentId":1,"firstname","abc","lastname":"def"}

0 个答案:

没有答案