REST

Representational State Transfer (REST) is an architectural style presented by Roy Fielding in the year 2000 for developing web services. It is built on top of the well-known Hypertext Transfer Protocol (HTTP) and can transfer data in multiple formats, the most common being JavaScript Object Notation (JSON) and eXtensible Markup Language (XML). The status of a request in REST is indicated using standard HTTP status code (200: OK, 404: Page not found!, and so on). Being based on HTTP, security is taken care of using the already familiar Secure Sockets Layer (SSL) and Transport Layer Security (TLS).

While writing such web services, you are free to use any programming language (Java, .NET, and so on) that is capable of making web requests based on HTTP (which is a de facto standard that every language supports). You have a number of well-known frameworks, using which developing RESTful APIs on the server side is quite easy and simple. Also, on the client side, there are a number of frameworks that make invoking RESTful APIs and handling responses straightforward and easy.

Since REST works on internet protocol, the caching of a web service response can be achieved quite easily by supplying appropriate HTTP headers (Cache-Control, Expires, and so on). The HTTP methods PUT and DELETE are not cacheable in any scenario. The following table summarizes the use of HTTP methods:

HTTP method

Description

GET

Retrieves a resource

POST

Creates a new resource

PUT

Updates an existing resource

DELETE

Deletes an existing resource

PATCH

Makes a partial update to a resource

Table 1: HTTP method usage

A REST API request/response (data sent over the wire) can be compressed by specifying appropriate HTTP headers, similar to caching. The HTTP header, Accept-Encoding, is sent by the client to the server, to let the server know the compression algorithms it can understand. The server successfully compresses a response and puts out another HTTP header, Content-Encoding, letting the client know which algorithm has to be used to decompress.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.167.224