What is Restful Architecture ?
REST is an architectural style(Wikipedia) that is used in Rails by default.
Restful Web Services is a stateless client-server architecture where web services are resources and can be identified by their URIs. REST Client applications can use HTTP GET/POST methods to invoke Restful web services.
Rest Principals:
Client-Server Architecture should be present
Stateless-> The server would not store any state, that is session information to identify the user over multiple subsequent requests. Each request should include some way of identifying the user.
Cacheable -> the request are cached on server to improve the performance of application
Uniform Interface -> All the client server interactions should use similar terminology and resources this helps standardize APIs. According to this principle, the following HTTP verbs are used: GET, PUT, POST, and DELETE. Resources always refer to URIs (uniform resource identifier). HTTP responses always come with a status and a body.
Layered system -> Developing a layered system improves the scalability of application
Types of HTTP request methods in rails
The application receives an HTTP request which carries along with it a method which could be:
GET - Retrieve a resource
PUT - Completely update a resource
PATCH - Partially update a resource
These methods determine which controller action method is called.
Subscribe to my newsletter
Read articles from shubhangi singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by