课间休息时按不同列获取资源
我对 RESTful Web 服务相当陌生,对 Recess PHP 框架更陌生。通过ID很容易检索资源。例如,如果我想检索 ID 为 7 的用户,我会向以下地址发出请求:
http://localhost/myApp/user/7
我想知道的是:是否有一个通过不同列检索资源的简单方法,例如用户的用户名?
http://localhost/myApp/user/username/tyler
这似乎对于 RESTful 框架来说非常重要,所以我猜有一种方法可以做到这一点或一种方法轻松实现它。
I'm fairly new to RESTful web services and even more new to the Recess PHP framework. It's easy to retrieve resources by ID. For example, if I want to retrieve a User with ID 7, I would make a request to:
http://localhost/myApp/user/7
What I'm wondering is this: is there an easy way to retrieve a resource by a different column, for example, a user's username?
http://localhost/myApp/user/username/tyler
This seems like it would be something pretty important for a RESTful framework to have, so I'm guessing there's a way to do this or a way to implement it easily.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想出了如何使用框架的参数路由系统来做到这一点。我创建了一个可以通过指定属性值检索用户资源的函数:
I figured out how to do this using the framework's parametric routing system. I created a function that can retrieve a User resource by a specified property value: