spring-projects / spring-projects/spring-data-rest

Custom Controller + changed base path doesn't show up in HAL [DATAREST-748]

Open
#1,120 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: repository type: bug
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:

  1. 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
  2. Using @BaseAwareController. The self-contained repro has this. It works only if @RequestMapping is also set.
  3. Leaving off @RequestMapping on 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.