简体   繁体   English

RESTFul路由和REST API

[英]RESTFul routes and REST api

I am currently working on Rails.I have read a lot of documents regarding REST api and RESTFul routes.But i am unable to figure out the relation between these two.My understanding for RESTFul routes is that a http verb is associated with them and i found out nothing else. 我目前在Rails上工作,我已经阅读了很多有关REST api和RESTFul路由的文档,但是我无法弄清这两者之间的关系。我对RESTFul路由的理解是http动词与它们相关联,而我一无所获。

Can someone please make these things clear? 有人可以说清楚这些吗?

1.What are RESTFul routes and their benefits? 1. RESTFul路线及其好处​​是什么?
2.In what way RESTFul routes are co-related with Rest Api? 2. RESTFul路由与Rest Api以何种方式关联?
3.What are the benefits of REST api over SOAP api? 3.REST api比SOAP api有什么好处?

I don't know Rails, but I can tell you the following: 我不了解Rails,但我可以告诉您以下内容:

1)The routes are defined in order to map an incoming request to a controller action. 1)定义路由是为了将传入请求映射到控制器操作。 A request is made of an HTTP method (GET/PUT/POST/DELETE), an URL and possibly some content in the body. 请求由HTTP方法(GET / PUT / POST / DELETE),URL以及正文中的某些内容组成。 For example GET books/1234 is a RESTful request for the book identified by the ISBN 1234 . 例如, GET books/1234是对由ISBN 1234标识的书的RESTful请求。 A framework like Rails has to map this request to a controller action. 诸如Rails之类的框架必须将此请求映射到控制器动作。 Such an action is an operation whose name is a verb. 这样的动作是名称为动词的操作。 In the router you have 2 main components for an entry: the request and the mapped action. 在路由器中,条目有2个主要组成部分:请求和映射的操作。 For example, in get '/books/:isbn', to: 'books#getBookByIsbn' what you say is that a GET request with an URL matching the given structure will be mapped to the action called getBookByIsbn from the controller books . 例如,在get '/books/:isbn', to: 'books#getBookByIsbn' ,您要说的是具有与给定结构匹配的URL的GET请求将被映射到控制器books名为getBookByIsbn的动作。

2)One benefit of RESTful services is that IMHO they are simpler, easier to user than SOAP/WSDL based services. 2)RESTful服务的一个好处是,恕我直言,它们比基于SOAP / WSDL的服务更简单,更易于用户使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM