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

Improve consistency between behavior of SDR's @BasePathAwareController and MVC's @RestController. [DATAREST-1493]

Open
#1,852 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: enhancement
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, @BasePathAwareController allows me to:
    • define endpoints without duplicating basePath (i.e. supports spring.data.rest.basePath)
    • use SDR support in my request handling (e.g. PersistentEntityResourceAssembler can be injected)
  • As opposed to @RepositoryRestController, @BasePathAwareController allows 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/sdr returns 406, while curl -i localhost:8080/api/mvc returns 200
  • curl localhost:8080/api/sdr -H "Accept: application/json" returns "sdr"%, while curl localhost:8080/api/mvc returns mvc% (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

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.