Adrian Stabiszewski
Adrian Stabiszewski

Reputation: 83

How to add additional links to the root resource in Spring Data REST?

The spring-data-rest module automatically scans for all repositories in an app and lists them like this:

{
"_links" : {
    "demoRepository" : {
    "href" : "http://localhost/demoRepository{?page,size,sort}",
    "templated" : true
    }
}

However I have some resources that are not backed by a database and don't have repository classes.

How can I add simple resources that have their own controller classes into the above list. Right now the list does not reflect the whole REST api of my app.

Upvotes: 1

Views: 2656

Answers (1)

palisade
palisade

Reputation: 486

You need to implement ResourceProcessor and then add Your custom links to RepositoryLinksResource. See https://stackoverflow.com/a/26118405/4090455

Upvotes: 3

Related Questions