REST
A client-server communication architecture(not a protocol).
Why it can't be a protocol?
AFAIK, there is no industry defined standards and it has only guidelines for those who want to create a web service using Rest concept.
What are all the guidelines?
Uniform Interface
This is the basic fundamental constraint for the REST web service architecture. This states that all services and service consumers within a REST-compliant architecture must share a single, same interface.
The interface between client and service is defined based on HTTP verbs (GET, POST, PUT/PATCH, DELETE), Resources (URI) and Representations.
In a payroll web service, the interface could look like
<uri> -> /api/identity/employees (identity is the service name and employee is the resource name and plural notation is preferred)
GET /api/identity/employees will return a json response in the following format,
{
{
id: "123AD232"
first_name: "suresh babu"
last_name: "prakasam"
................................
................................
},
{
id: "456AD232"
first_name: "kokila"
last_name: "suresh babu"
................................
................................
}
}
Stateless
Each request to the server should contain enough information to get the response back to client.
Why the hell, server need to maintain the state of a client application?
Cacheable
Add
Last-Modified
header with RFC-1123 timestamp format. It is preferred over ETag as the value is more meaningful. Please note If-Modified-Since
header, which is used to validate against Last-Modified
, may send the timestamp inthree different formats and the server side needs to handle all of the three formats.Client-Server
Client and Server have a formal contract for communication so the client implementation or server implementation can be replaced without any impact for the service interface.
Layered System
Client should not assume that it has direct connection to the server. The server side system includes CDN caching, Load balancer, Web server filters etc.,
Code on Demand (Optional)
References
- http://www.restapitutorial.com/lessons/whatisrest.html
No comments:
Post a Comment