假设我有一个GET /api/foos/{id}
具有可选参数的端点:包含、查询、类型我应该为每个“用例”创建一个链接还是可以将其作为单个链接包含在内?
它应该看起来更像这样:
"_links":{
"self": { "href": "/api/foos/1" },
"includes": { "href": "/api/foos/1{?includes}", "templated": true },
"query": { "href": "/api/foos/1{?query}", "templated": true },
"type": { "href": "/api/foos/1{?type}", "templated": true },
}
或者可能是这样的:
"_links":{
"self": { "href": "/api/foos/1" },
"query": { "href": "/api/foos/1{?includes}{?query}{?type}", "templated": true },
}
如果我也有与分页相关的链接,例如 next、prev 等,我是否也应该为它们包括这些模板?例如:
"next": { "href": "/api/foos?page=2{?includes}", "templated": true }