Answer
What is REST?
REST stands for Representational State Transfer. It is an architectural style for developing web services that:
- ✓Exploits the ubiquity of the HTTP protocol
- ✓Uses HTTP methods to define actions
- ✓Revolves around resources — every component is a resource that can be accessed through a shared interface
REST Architecture
- ✓REST Server provides access to resources
- ✓REST Client accesses and modifies those resources
- ✓Each resource is identified by URIs (Uniform Resource Identifiers) or global IDs
- ✓Resources can be represented in text, JSON, or XML
6 REST Constraints (Principles)
| Principle | Description |
|---|---|
| Stateless | Each request contains all info needed; server stores no session state |
| Client-Server | Client and server are independent and separated |
| Cacheable | Responses must be labeled cacheable or non-cacheable |
| Uniform Interface | Consistent way to interact with resources |
| Layered System | Client can't tell if connected directly to server or middleware |
| Code on Demand | (Optional) Server can send executable code to client |
Statelessness Explained
The client and server don't store information about each other's state. Since the server stores no information, it treats each request as a new request.
- ✓The client request must contain all information required for the server to process it
- ✓Client application is responsible for storing session state
