REST 架构 - 资源和方法
在基于 REST 的架构中,资源和方法之间有什么区别。有吗?
In REST based architectures what's the difference between a resource and a method. Is there one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
资源是您的应用程序定义的东西;它们与物体非常相似。方法是 HTTP 动词之一,例如,
GET
、POST
、PUT
、DELETE
。它们与在您的资源上调用的方法类似。我真的建议您阅读 架构风格和基于网络的架构设计(Fielding 博士的论文,他在其中定义了 REST)和/或 RESTful Web 服务,它很好地展示了如何将理论付诸实践。
A resource is something your application defines; they're very similar to objects. A method is one of the HTTP verbs, e.g.,
GET
,POST
,PUT
,DELETE
. They are similar to methods that get invoked on your resource.I really recommend you read Architectural Styles and the Design of Network-Based Architectures (Dr. Fielding's dissertation, where he defines REST) and/or RESTful Web Services, which does a stellar job of showing how to put the theory into practice.
阅读 RESTify DayTrader 帮助我理解了这个概念。他非常得体地解释了如何从“动作”的描述转变为一系列 URI 和这些 URI 上的方法。
Reading RESTify DayTrader helped the concept sink in for me. He explains pretty decently how to go from a description of "actions" to a series of URIs and Methods on those URIs.
资源是分布式应用程序设计者决定为其创建 URL 的一个有趣的状态。
可以是资源的标识符。正如可能的那样,
方法是可以对该资源执行的动作或操作。例如
A resource is an interesting piece of state that a distributed application designer has decided to create a URL for.
may be an identifier of a resource. As may,
A method is an action or operation that can be performed on that resource. e.g.