This post aims to explain the following :
– What are REST architectural principles ?
– What is HATEOAS ?
Here are the architectural principle in REST :
Addressability
In REST, URIs are used to address a resource.
Each HTTP request must contain URI of the object whose state is being accessed or updated.
Uniform and Constrained interface
In REST, we only use the methods of HTTP for our service such as :
GET : access a resource from server
PUT : add resource
DELETE : removes resource
POST : modify the resource
HEAD : similar to GET, but instead of returning a response body, it returns a response code along with any headers present
OPTIONs: request information about communication of resource
Representation-oriented
REST services are representation oriented and representation are transfered between the client and service.
The representations can be text, xml, html, json etc
With a GET operation, the client receives the current state of the resource.
A PUT or POST passes representation of a resource to the server, so that the underlying resource’s state can change.
Stateless
REST services are stateless by nature. So, the clients state can not be stored on the server.
However, the client can still maintain state and pass it to the service with each request.
HATEOAS
HATEOAS concept is Hypermedia As The Engine Of Application State.
Its about using hypermedia and hyperlinks for providing complex information through the service.
Hyperlinks allow us to reference and aggregate additional data without bloating the service response.
For example, if your service returns different products, then rather than sending all the products in the response, it can send 5/10 products and then provide a link that would request for the next set of products.
This makes the response lite and the service flexible.
© 2015 – 2016, https:. All rights reserved. On republishing this post, you must provide link to original post
#
“HEAD : similar to HEAD”… 🙂
#
Thanks Nir.. description for HTTP methods updated
#