spring-projects / spring-projects/spring-data-rest
How to add custom links to repositories
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Hey all,
I'm trying to add a custom link to the repository URL but so far I've been unsuccessful.
Currently I have a custom query in my Repository (using the standard Spring data JPA method of extending single repositories) but now I'd like to expose that query method from within the repository with a HATEOAS link.
For example:
"links": [
{
"rel": "concept.search",
"href": "http://localhost:8080/trialverse/concepts/search"
},
{
"rel": "concept.treatments",
"href": "http://localhost:8080/trialverse/concepts/treatments"
}
]
I know you can add a ResourceProcessor<Resource<?>> to add links to a Resource, but is there a similar construct for the repositories themselves?
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.
Research direction
The issue names no files or tests; start by locating repository resource assembly and the ResourceProcessor<Resource<?>> extension point. Trace how Spring Data JPA custom query methods are exposed, then define a supported mechanism for adding HATEOAS links and tests covering the example repository links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100