简体   繁体   中英

Implementing a RESTful API resource

Every resource online I have been able to find on the subject of restful api uri only covers standards and practices. But how does one develop a restful uri? This entire time I have developed web pages with extensions. How does one make a page without extensions? I am very confused.

Restful APIs are generally served by URL rewriting or forwarding; the 'pages' are not exactly pages but requests to a service. So something like this:

 myco.com/people/jonny/house

Would be the resource for Jonny's house. But there is no page as such, just a service that sees that and either directly calls requestPerson('jonny').house or perhaps rewrites it as a page request that can be fulfilled.

Try to see it less as a file location and more as a request string, so it is more like myco.com/people , which is being asked for 'jonny/house' .

The two things to do when developing a RESTful interface are to decide on your data structure and decide on your request structure/mapping. So you have people and cars, and you permit requests for people, cars, or both. To some degree it is like querying a database via stored procedures; the procedures have to be set up to respond to queries, and they will do so in a predictable manner. The difference is that there is an engine managing the requests and responses, and the responses are generally in html format (though they can be JSON, XML, etc).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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