I'm using Spring Data REST. RepositoryRestResource
annotation has two different fields: path
and collectionResourceRel
. What's the difference between those two? I can't figure this out by reading the documentation.
path
is described:
The path segment under which this resource is to be exported.
and collectionResourceRel
is described:
The rel value to use when generating links to the collection resource.
In all code examples I've seen these two properties where the same. Is there any case when they differ? And what is the actual difference between them?
For example, for entity User
the default values will be:
path = users
itemResourceRel = user
collectionResourceRel = users
Example:
GET /users (path: users
)
"_links": {
"self": {
"href": "http://localhost:8080/api/users"
},
"users": { <-- collectionResourceRel
"href": "http://localhost:8080/api/users"
}
}
GET /users/1 (path: users
)
"_links": {
"self": {
"href": "http://localhost:8080/api/users/1"
},
"user": { <-- itemResourceRel
"href": "http://localhost:8080/api/users/1"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With