spring-projects / spring-data-rest

Simplifies building hypermedia-driven REST web services on top of Spring Data repositories
https://spring.io/projects/spring-data-rest
Apache License 2.0
914 stars 561 forks source link

Allow user to order rest handler mapping [DATAREST-896] #1265

Open spring-projects-issues opened 8 years ago

spring-projects-issues commented 8 years ago

Petar Tahchiev opened DATAREST-896 and commented

As indicated here

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMapping.java#L85

the RequestMappingHandlerMapping has order 0.

At the moment DelegatingHandlerMapping is registered with Ordered.LOWEST_PRECEDENCE - 100; so it is always after RequestMappingHandlerMapping. In a typical spring-boot application I would love to be able to configure the order. The best combination in my oppinion would be:

1) Some custom handler mapping or maybe h2-console?
2) Spring boot actuators
3) Spring data rest handler mapping 
4) RequestMappingHanderMapping (has order 0)
5) Static resources

but at the moment it is like this:

1) Some custom handler mapping or maybe h2-console?
2) Spring boot actuators
3) RequestMappingHanderMapping (has order 0)
4) Spring data rest handler mapping 
5) Static resources

In my application I have a DefaultController which always kicks in if there's no controller mapping, so I never get to the REST handler mapping.


Affects: 2.5.2 (Hopper SR2), 2.6 M1 (Ingalls)

3 votes, 6 watchers

spring-projects-issues commented 8 years ago

Oliver Drotbohm commented

Spring Data REST's RepositoryRestHandlerMapping is deploy after the plain Spring MVC one to allow overriding Spring Data REST resources manually. You can react to missing handler mappings using an appropriate exception handler

spring-projects-issues commented 7 years ago

Aurélien Leboulanger commented

Does any by-pass exist before this issue can be done ? I have the same use case which is to set the spring data rest mapping order before the spring mvc.

spring-projects-issues commented 7 years ago

Florian commented

I guess I'm falling into the same issue. Still looking for a workaround. Any help/update on that topic ?