【发布时间】:2017-08-06 15:15:26
【问题描述】:
我正在使用超媒体概念设计一个 API。我看到有一个返回其他 API 链接以进行导航的根路由是一个很好的做法。
例如:我向 http://myapi.com 发出请求,它返回
{
links: [
{ 'rel': 'profile', href: '/profile' },
{ 'rel': 'orders', href: '/orders' },
{ 'rel': 'order_types', href: '/order_types' },
...
]
}
但是,这样一来,如果根有 20 个资源,它会非常大。
那么,直接向 order_types 请求,而不是请求 root,然后请求 order_types 是一种反模式吗?
【问题讨论】:
标签: api hateoas hypermedia