-
Notifications
You must be signed in to change notification settings - Fork 472
Also support optional HAL Link fields #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm frankly kind of surprised that Link isn't an interface (particularly since they are usually built with Builders rather than being instantiated directly). Also, why is the Atom namespace is coded directly onto the class? This makes it difficult and cumbersome to support HAL and in some cases actually deviates from Atom expectations. For instance, since href in HAL can be a URI template if the templated property is set to true, that means that the value in some cases is non RFC-5899 compliant. I'm all for having Link be a link abstraction, but right now it seems like it's too close to Atom. |
I've done a lot of searching and this post seems to be the closest I've got to figuring out if I can build HAL template resource links with Spring HATEOAS. e.g "http://host/resource1/{id}/subResource". The answer appears to be "no". At best it tries to encode the "{", "}" chars, thinking I am trying to build a valid URL, not a templated one per http://tools.ietf.org/html/rfc6570. |
drewcox: My fork adds a method to the Link class that renders the HAL |
Hey, thanks for the quick response. Kind of new to GitHub, is it possible for me to access your fork? Thanks Drew |
Yes. It's at https://github.com/fiddlerpianist/spring-hateoas. Look for recent commits from me. |
I'm trying to figure out how to build HAL links with "templated: true". If I use
The '{' and '}' chars are still encoded. Any idea how to build template URL links with Spring-hateoas 0.10.0.RELEASE by its API? Thanks. |
jiwhiz: you have a solution for the templated: true? |
@rodriguezrps yes, found some tricks. I can use UriTemplate to build link directly with template, such as
And use PagedResourcesAssembler to append pagination templates:
You can see examples at my blog https://www.jiwhiz.com/post/2014/4/Design_and_Build_RESTful_API_with_Spring_HATEOAS |
@edrik : can you please post your solution? It'd be very helpful. |
There is nothing special about the solution I'm using now. Its a extended version of the Link class that adds the attributes and can be construkted from an existing Link. Just need to do some extra wrapping in some places but its a reasonably workaround. CustomLink halLink = CustomLink.of( plainLink ).setTitle("Foo") |
@edrik |
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Adds many additional attributes defined in RFC5988 and verifies they work properly in the neutral representation of Link while also being rendered properly in the HAL module. Additionally, some of the files had inconsistent EOL characters. This patches that as well. To see the differences WITHOUT this bit, add ?w=1 to the github page showing the delta, and whitespace differences will be filtered out. Resolves #100,#417,#235,#240,#238,#223
Fixed with #567. |
The HAL support so far is great but for it to be really usable the optional link fields defined by the HAL specification should also be available.
There is a pull request #79 about adding a type and title but there are allot more optional fields defined by HAL. Not sure if adding all the fields to the Link class is the best solution but that would be a quick fix.
So far I've used a extended version of the Link class that adds the fields (and a fix for the issue with selecting the appropriate JsonSerializer, also noticed by #88). But that is far from ideal and makes allot of the convenience method unusable.
Any thoughts on how this could be implemented in a reasonably unobtrusive manner?
The text was updated successfully, but these errors were encountered: