RESTful API - HATEOAS

Slack Discussion Repositories https://github.com/terawarehouse/terawarehouse-catalog https://github.com/terawarehouse/terawarehouse-react To...


Slack Discussion

Repositories
To enable HATEOAS, spring-boot-starter-hateoas dependency must be added to your pom.xml file.

HATEOAS or Hypertext as the Engine of Application State is a guideline for the client to navigate to the relevant information for a given resource. For example, if you have an entity resource, it makes sense to also return the list URL for that entity as well as the link for the entity itself.

[open CategoryController class]
There are 2 main classes that we need to remember when implementing HATEOAS, Resource, and Resources. Resource must be parameterized with the entity that it is handling. For example: Resource. This will return the category object plus the related links like self and list. 

In the one() method, the category object is wrapped into a Resource object and links are set before it is returned.

[show one() method]

As the name implies, Resources takes on an array of Resource<> eg. Resources>.

[show all() method]

Now start the Spring boot application.

[run oneCode and all tests in Postman]

[open categoryResourceAssembler class]

If you will notice in our class we have this categoryResourceAssembler class. It contains a utility function that wraps an entity in a Resource object. It’s really important as it saves you a lot of time writing the common links for a given entity.

There are times when we simply want a subset of the entity’s field in the response and that’s what we will present in the next video. So see you there!

COMMENTS

mas template
Name

amazon,1,angular,8,bigdata,2,business,1,course-spring,27,courses,6,database,4,docker,3,java,50,kafka,1,keycloak,4,microservices,5,mysql,1,neworking,1,nosql,2,php,1,pinned,2,react,3,server management,7,shared drive,1,spring,7,synology,1,troubleshooting,2,web,1,wordpress,1,
ltr
item
toztech: RESTful API - HATEOAS
RESTful API - HATEOAS
https://i.ytimg.com/vi/Igvxl2_Htps/0.jpg
https://i.ytimg.com/vi/Igvxl2_Htps/0.jpg
toztech
https://toztech.blogspot.com/2019/07/restful-api-hateoas.html
https://toztech.blogspot.com/
https://toztech.blogspot.com/
https://toztech.blogspot.com/2019/07/restful-api-hateoas.html
true
2554149350007112447
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content