spring-projects / spring-projects/spring-data-rest
Custom Controller + changed base path doesn't show up in HAL [DATAREST-748]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
George Hilios opened DATAREST-748 and commented
Hi, I've created a custom controller to access a custom repository. I use ControllerLinkBuilder to add a link to the resource in HAL when accessing the root, and also change the base path to "/api". I cannot get a correct link (under /api) to show up in HAL for the custom controller.
What I've tried:
- Using
@RequestMapping("/samples"). HAL link is correct (http://localhost/api/samples), but it also serves the request on http://localhost/samples because of the RequstMappingHandler. I need everything outside of /api to go to React, so that won't work for me - Using
@BaseAwareController. The self-contained repro has this. It works only if@RequestMappingis also set. - Leaving off
@RequestMappingon the type, but including it on the methods. The /api endpoints work perfectly, but HAL only shows http://localhost
I've included a completely self-contained repro with unit tests to show what I expect: https://github.com/ghilios/SDR-HATEOAS-issue
Reference URL: https://github.com/ghilios/SDR-HATEOAS-issue
3 votes, 6 watchers
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.