Intro
Representational state transfer (REST) is a style of software design architecture.
RESTful Constraints
In order to be RESTful, the architecture must comply to the following contraints.
- Client-server:
- Separation of concerns into client and server (loose coupling):
- Client focuses on UI
- Server not concerned about UI
- Separation of concerns into client and server (loose coupling):
- Stateless:
- No client context is stored on the server between requests.
- All session state is stored in client.
- Server can be stateful, but every server side state need to be addressable by URL as a resource.
- Cacheable:
- All responses must indicate to client if they are cacheable.
- Layered system:
- Client does not know about the end server (Allow intermediary servers)
- Code on demand (optional):
- Servers can temporarily extend or customize the functionality of a client by transferring logic (e.g. JavaScript) to the client.
- Uniform interface
- Uniform interface decouples client and server to achieve separation of concerns.
RESTful Web Services
RESTful web servies implement web services:
- Using HTTP
- Compliant with RESTful constraints.
A RESTful web service must define:
- Base URI (e.g. http://example.com/resources).
- Supported data type (e.g. JSON, XML).
- Supported operations using HTTP methods (e.g. GET, PUT, POST, or DELETE).
- API that is hypertext driven.
References