如果您正在考虑在您的应用程序中实施超媒体,以便在给定位置为客户端提供一组可能的操作(与其他适当资源的URI进行链接),那么/things
URI是发送GET这些链接。
以下是对/things
资源的GET示例结果。这种方法的优点是,客户端可以被编码为在Links
中查找Rel
值,而不必“知道”如何构建URI。即使客户端确实需要构建到URI,它仍然可以在搜索链接href中用于搜索项目(如{searchTerm}
)的编码以替换为适当的值。
"Things": [
{
"Description": "Resource level properties that make sense to put here",
"Count": 33,
"Links": [
{
"Rel": "self",
"Method": "GET",
"Href": "http://yourDomain/things",
"Title": "Things resource"
}
]
}
],
"Navigation": [
{
"Links": [
{
"Rel": "GetItem",
"Method": "GET",
"Href": "http://yourDomain/things/{id}",
"Title": "Get a single item"
},
{
"Rel": "Search",
"Method": "GET",
"Href": "http://yourDomain/things/?searchTerm={searchTerm}&itemsPerCall={itemsPerCall}",
"Title": "Search items per term"
}
]
}
]