Just came across this term HATEOAS , which some of my team members were using in describing what we did in our previous project wrt to REST.
My Last project was about building an e-commerce platform for one of the largest book publisher and distributor in Latin America.As part of that project we had thought to use the LEVEL-3 for rest communication which is using REST as a hypermedia controls.
You can read about different levels of REST at this Martin Fowler’s Blog .
When we said we wanted to use REST as hypermedia controls , the main idea behind this was to be able to navigate the result of a REST call.
For Example if there is a product catalogue call which looks like
GET /products/123456
So It would return
As you can see that apart from the the properties of the product 123456 it also has a links array.
This links array contains the the link description in rel and the location of that document.
so essentially what i could do is parse the JSON response , and then look for what all things can be done on that product.In this case we have exposed two actions , one for the self and the other to place an order for that product.Then to place an order would be to simple do a post on the the href for rel = “order”
The biggest advantage of this scheme is that , you are not dependent on the uri schemes of API , since every time you are navigating the href , if if the API provider changes the url’s you will not be affected . All you need is an entry point in the API and then you can navigate from there on.
This specifically helps during the development process too , as you can change the routes of the API without worrying about breaking the tests anywhere else .
Comments
Post a Comment