A REST application program interface(API) is an interface style that has a set of constraints. These constraints must be satisfied in order to consider it to be RESTful. When these constraints are properly followed, the product would be an application with specific properties. These properties will result in better performance and reliability.
Constraints- in simple words or less…
- Client–server- The client/server application must be separated and able to progress without depending on each other.
- Stateless- all client server interactions are stateless. If state management is needed, it should take place on the client. The server does not need context of what state the client is in.
- Uniform interface- Predictability, utilizing proper HTTP Verbs, self descriptive, and uniform- like exposure to resources
- Cacheable- Caching should be allowed on all resources unless distinctively told not possible
- Layered system- Layered style architecture made from hierarchical layers of servers.
Code on demand (optional)- Well, this constraint is optional. Most of the time, you will be sending the static representations of resources in the form of XML or JSON. Servers can also send executable code to the client.
In the image above, is a table describing the our Seven routes. Each route supply’s mapping between HTTP verbs and our controller actions.These Routes receive request(GET/POST/PATCH/DELETE) and determines what needs to be sent back. Although not the same, CRUD(Create, Read, Update, delete) can be synonymous to our action names. These seven routes are responsible for access and manipulating our resources. Since our routes and have already been assigned, CRUD allows us to focus more on the app itself .
CRUD takes care of these four actions, and can be used as many times as needed. RESTful routing is the current standard for routing in Rails, so please try to utilize this format when creating future products. Predictability makes coding easier, and makes the user experience more friendly. Thank you for reading. Be sure to checkout my blog on more RESTful routes here!