-
Book Overview & Buying
-
Table Of Contents
Spring: Microservices with Spring Boot
By :
Representational State Transfer (REST) is basically an architectural style for the web. REST specifies a set of constraints. These constraints ensure that clients (service consumers and browsers) can interact with servers in flexible ways.
Let's first understand some common terminologies:
Some of the important REST constraints are listed as follows:
/users/Jack/todos/1. In this, URI Jack is the name of the user. 1 is the ID of the todo we would want to retrieve.An example response with the HATEOAS link is shown here. This is the response to a request to retrieve all todos:
{
"_embedded":{
"todos":[
{
"user":"Jill",
"desc":"Learn Hibernate",
"done":false,
"_links":{
"self":{
"href":"http://localhost:8080/todos/1"
},
"todo":{
"href":"http://localhost:8080/todos/1"
}
}
}
]
},
"_links":{
"self":{
"href":"http://localhost:8080/todos"
},
"profile":{
"href":"http://localhost:8080/profile/todos"
},
"search":{
"href":"http://localhost:8080/todos/search"
}
}
}The preceding response includes links to the following:
http://localhost:8080/todos/1)resource (http://localhost:8080/todos/search)If the service consumer wants to do a search, it has the option of taking the search URL from the response and sending the search request to it. This would reduce coupling between the service provider and the service consumer.
The initial services we develop will not be adhering to all these constraints. As we move on to the next lessons, we will introduce you to the details of these constraints and add them to the services to make them more RESTful.
Change the font size
Change margin width
Change background colour