OpenRasta - 为列表资源提供过滤、排序和分页
我们正在使用 OpenRasta 创建一个 REST API,除了对所有资源进行常规 GET、POST、PUT 和 DELETE 之外,我们还对具有复数名称的资源提供 GET。因此,API 的使用者可以对 User
执行 GET、POST、PUT 和 DELETE,还可以对 Users
执行 GET,这将返回 List
。现在我们希望客户端能够根据其属性对其进行过滤和排序,并允许支持分页以分页表格格式显示数据。
虽然,我查看了 WCF 数据服务工具包 主页,看起来它可能很有用,但在查看了博客文章之后和入门页面,我无法理解如何使用它来解决 OpenRasta 中的问题。
或者还有其他更简单的事情我可以做吗?
We are creating a REST API using OpenRasta and apart from regular GET, POST, PUT and DELETE on all resources, we are also providing GET on resources with plural names. So a consumer of the API can GET, POST, PUT and DELETE on User
and also perform GET on Users
which will return List<Users>
. Now we want the clients to be able to filter and sort it by it's properties and allow to support paging for showing data in paged tabular formats.
Although, I looked at WCF Data Services Toolkit home page and looks like it can be useful but after looking at blog posts and Getting Started page, I couldn't understand how I can use it to solve my problem in OpenRasta.
Or is there anything else simpler that I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
OR 不支持 OData 之类的功能,主要是因为它会导致系统非常不稳定。
如果 /users 是“用户列表”,那么它与 /users/1(用户的第一页)或 /users/byName/1(按名称排序的用户的第一页)是不同的资源。
当然,您可以通过注册具有查询参数的 URI 来轻松实现所有这些,因为这些参数是可选的
并且您的处理程序可以如下所示
OR doesn't support stuff like OData for that functionality, mainly because it leads to very unrestful systems.
If /users is "the list of users", then it is a different resource than /users/1 (the first page of users) or /users/byName/1 (the first page of users ordered by name).
You can of course implement all this easily by registering a URI that has query parameters, as those are optional
And your handler can look like