Hi I am using spring data rest with Jpa in my project to expose HAL based rest webservices .It works well for most of my cases and for further customization I do use additional controllers and call spring data repositories to fetch data for me and use hateos resource for displaying those with links exposed via hateos entityLinks .This is great and works for most of my use cases . Now I have a few additional requirement wherein I want to put etag headers for server caching and instance level version link headers [https://www.rfc-editor.org/rfc/rfc5988] more specific https://www.rfc-editor.org/rfc/rfc5829#page-3 as below for my responses .
GET /81822 HTTP/1.1 ...
HTTP/1.1 OK
Host: dumbserver.com
Content-Type: application/json
Link: </81822 ;v=1.1>; rel="previous";
</81822 >; rel="current";
</81822 /version-history>; rel="version-history";
{
Is this possible via using hateos interfaces or will I have to go for a custom approach by adding these via HttpServletResponse or responseentity.getHeaader and add custom code for handling versioning .I think Spring data rest or hateos must work on providing abstractions for these as well.
I think you pretty much have to roll your own once you override a Spring Data Rest endpoint from a controller, even if your controller is annotated with
@RepositoryRestController
.We did this by creating a base controller that is responsible for wrapping our
entity
as aResource
which in turn gets wrapped in aResponseEntity
Our
ETag
happens to be based on the entityversionNumber
which has a@Version
annotation.