spring-projects / spring-projects/spring-data-rest
Improve consistency between behavior of SDR's @BasePathAwareController and MVC's @RestController. [DATAREST-1493]
@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
jvanheesch opened DATAREST-1493 and commented
My understanding of @BasePathAwareController is as follows:
- As opposed to
@RestController,@BasePathAwareControllerallows me to:- define endpoints without duplicating
basePath(i.e. supportsspring.data.rest.basePath) - use SDR support in my request handling (e.g.
PersistentEntityResourceAssemblercan be injected)
- define endpoints without duplicating
- As opposed to
@RepositoryRestController,@BasePathAwareControllerallows me to handle urls outside of the SDR URI space.
Is this indeed what @BasePathAwareController is intended for?
Regardless of whether or not this is correct, there are several behavioral differences (see reference url).
Consider a @BasePathAwareController endpoint with MediaType.APPLICATION_JSON_VALUE (/api/sdr) and a similar @RestController endpoint (api/mvc), then:
curl -i localhost:8080/api/sdrreturns406, whilecurl -i localhost:8080/api/mvcreturns200curl localhost:8080/api/sdr -H "Accept: application/json"returns"sdr"%, whilecurl localhost:8080/api/mvcreturnsmvc%(i.e.: quotes vs no quotes in response body).
I believe the simple SDR endpoint should work out-of-the-box and exhibit the same behavior as the MVC endpoint.
Reference URL: https://github.com/jvanheesch/spring-data-rest-basepathawarecontroller-vs-restcontroller
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.