-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an API for introspection of handler mappings [SPR-15934] #20488
Comments
Rossen Stoyanchev commented Typically there should be no need to open separate tickets for Spring MVC and WebFlux. The default assumption for us is to to consider the impact to both regardless of which side the ticket came from. So I'm consolidating this with #20489 which would duplicate the same discussion. |
Andy Wilkinson commented Noted. Thanks, Rossen. |
Rossen Stoyanchev commented What exactly would you like to see? On the WebFlux side DispatcherHandler is already a bean and we could easily add a method that returns the HandlerMapping beans it detected. If we did something similar for Spring MVC, I suspect Boot would be able to access such a property on the DispathcerServlet? Beyond access to HandlerMapping's the actual mapping metadata is different between SimpleUrlHandlerMapping (just patterns) and Also can you point me to the Actuator code that does this? I don't understand why it doesn't detect Spring Data REST mappings, nor why is it hard to have the mappings sorted according to HandlerMapping order, and/or stored in something other than a map. |
Andy Wilkinson commented Accessors on both DispatcherServlet and DispatcherHandler would, I think, be a big step in the right direction.
The current implementation relies on the
The current code is here: https://github.com/spring-projects/spring-boot/blob/1.5.x/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java. IIRC, the Data REST mappings aren't detected because its handler mapping is a black box. I should open a separate DATAREST issue for that. There's nothing particularly hard about sorting the mappings, but we'd have to duplicate the logic in We will move from returning a map of the mappings. Given that the ordering is important a list would be more appropriate. We'll do that irrespective of the outcome of this issue. |
Rossen Stoyanchev commented Sorry for the slow response. I've added getters on both sides. What else would you like to see? |
Andy Wilkinson commented Thanks, Rossen. Those getters go a pretty long way to giving us what we need, particularly if I consider different mappings by their concrete type (there's lots of useful information in |
Rossen Stoyanchev commented I've added a getter for RouterFunction. Note that it will return null if called before initialized when in the mode of detecting. I've done the same for both getHandlerMapping methods to align the behavior and to provide a clear signal when not yet configured. |
Andy Wilkinson opened SPR-15934 and commented
Spring Boot provides an Actuator endpoint that aims to list all Spring MVC (or WebFlux) mappings. It's current implementation is rather haphazard in terms of what it does and does not list, and the format in which mappings are listed. Please see some of the comments and concerns raised in spring-projects/spring-boot#9979 for more details.
Would it be possible for Spring MVC and WebFlux to provide a supported API for introspecting DispatcherServlet and DispatcherHandler handler mappings respectively? I think Boot's current implementation could, in some ways, be improved by reflectively accessing
DispatcherServlet.handlerMappings
and burrowing down from there but that would still be something of a hack.Affects: 5.0 RC3
Reference URL: spring-projects/spring-boot#9979
Issue Links:
Referenced from: commits 41b53de, 9ff4c0b, 819ca0d, c28a635
The text was updated successfully, but these errors were encountered: