How to RESTFul your services and RESTFul services

Source: Internet
Author: User
Tags representational state transfer

How to RESTFul your services and RESTFul services

Original article: http://reynders.co/how-restful-is-your-service/
Published on: February 1, September 2013

Today, neither social media platforms nor Enterprise Solutions nor Web services are available. To be cross-platform, it is very important to "expose" Your APIs. Currently, many APIs claim to be RESTful on the surface, but they are actually improved RPC.

Many services that claim to implement the REST style do not even know what it means. So I will explain what REST is and tell you how to RESTful your services.

REST and RESTful

As defined by Roy Fielding, Representational State Transfer (REST) is a software architecture style of distributed systems. For example, Web depends on a stateless (stateless), client-server, and cache-able communication protocol, such as HTTP.

/This/does/not/mean/restful, {"neither": "does this "}

Having a clear and smooth route and returning JSON data does not mean your service is already RESTful. Only when the REST style is adopted and certain rules are followed are truly RESTful services.

Fielding points out the six constraints required by RESTful, of which at least five should be taken seriously:

1. Client-Server constraints (Client-Server constraint)

Use a unified interface to isolate the client and server. The client does not have to care about the business logic and data storage. Similarly, the server does not have to consider the user interface.

2. Stateless constraint) 

Each request contains all the information required by the server. The server does not store the status information.

3. Cache-able constraint) 

The server response must be able to explicitly or implicitly define itself as a cache-able, allowing the client to reuse the response and reduce frequent calls to the server to improve performance.

4. Layered System constraint)

The client does not need to consider intermediary components, such as load balancing and proxy, to improve system scalability.

5. unified Interface constraints (Uniform Interface constraint) 

The client and server use a uniform HTTP-based URI to locate resources. As mentioned above, each piece Of information contains sufficient information for The server to complete subsequent processing, namely, HATEOAS (Hypermedia As The Engine Of Application State ).

6. Code On Demand constraint) 

Optional constraints. Before the server returns information, the client does not need to know how to process the information. It is usually used to add features to a deployed system.

RESTful Web APIs 

Implementing RESTful Web application interfaces and RESTful Web APIs Based on HTTP includes the following features:

  • Basic URI, for example: http://api.mysystem.com
  • Supports Internet media types, such as JSON
  • Use HTTP verbs: GET, POST, PUT, DELETE to complete the operation.
  • Hypertext driven)

RESTful Web APIs must be easy to use and provide complete help documentation.

"If you have to ship an SDK for your RESTful API, it is not a RESTful API" - source 

The ASP. NET development team provides a REST-based Web API development framework, called ASP. NET Web API. Click here for additional reading.

Note

The aforementioned constraints are not a standard, but they are the best guide for building RESTful Web applications.

Currently, there are only a few applications that truly implement the RESTful concept, most of which are RPC based on HTTP protocol improvements. Next time you study a new API, you can see if it is truly RESTful.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.