spring-hateoas-examples | build hypermedia-driven apps | REST library
kandi X-RAY | spring-hateoas-examples Summary
kandi X-RAY | spring-hateoas-examples Summary
This repository contains example projects to interact with Spring HATEOAS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Process an Order .
- Create database .
- Update an Employee .
- Compares two Order objects .
- Get the collection link builder .
- Returns the index of employees .
- Set the name of the field
- Add employees .
- DS customizer for the hypermedia REST template .
- Returns a list of employees .
spring-hateoas-examples Key Features
spring-hateoas-examples Examples and Code Snippets
Community Discussions
Trending Discussions on spring-hateoas-examples
QUESTION
I am using spring boot version 2.0.6
which comes with HATEOAS version 0.25
. I am using a resource assembler that utlises ControllerLinkBuilder
to generate resource links. However, the problem is it generates relative links, how to configure it to use a host
and port
scheme from either request headers (the app will run as a docker container in dev, qa and prod) or config properties when running it locally from IDE.
I get link that respects X-Forwarded-Host
header
ANSWER
Answered 2018-Dec-21 at 23:47The UriComponentsBuilder
in spring-hateoas calls RequestContextHolder.getRequestAttributes()
to get the request attributes. These are attached to the thread by the dispatcher servlet. As you're using DeferredResult, you will already have returned the thread with the request attributes. The thread being used to build the links doesn't have any request attributes on it. This results in relative paths being used.
There are a couple of issues about it already, but they don't suggest that there is anyway you can use any properties to set the base url. Which seems a shame.
- Issues using hateos with defferedresult #574
- ControllerLinkBuilder.linkTo throws error if called outside of the context of a HTTP request #408
There are a few simlar questions, the answers seem to suggest you need to pass the request details to the new thread. Here's a couple in case you haven't found them already.
QUESTION
I have the problem similar to one asked in this question however, applying the suggested solution
spring.jackson.default-property-inclusion=NON_NULL
does not stop HATEOAS from rendering links with null properties. Here's my controller declaration
ANSWER
Answered 2018-Dec-17 at 05:40The problem was in my configuration class, I was registering the Hibernate5Module in a wrong way, removed these lines
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-hateoas-examples
You can use spring-hateoas-examples like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the spring-hateoas-examples component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page