11

I'd like to have a way how to expose all endpoints that exposed by my Spring application. Is there a simple way to check, for each @profile which are exposed?

Example:

GET   /api/resource
GET   /api/resource/list
POST  /api/resource
PUT   /api/resource

In the past, I have used a web application made in Laravel, and they had a simple cli method for checking the exposed methods.

Jack Sierkstra
  • 1,394
  • 2
  • 18
  • 41
  • http://stackoverflow.com/questions/28993724/is-there-a-way-to-discover-all-endpoints-of-a-rest-api – James Jithin Nov 06 '15 at 14:54
  • Sorry, but this doesn't remotely answer my question. My question is targeted at Spring Framework. I have access to my own code, so I won't brute force my own application. Furthermore, you can expect such functionality of a relatively mature framework as Spring. The endpoints are somewhere registered (Spring Container??), so there must be a way to iterate through them. – Jack Sierkstra Nov 06 '15 at 17:29
  • 1
    http://stackoverflow.com/questions/11082818/spring-mvc-get-all-request-mappings – James Jithin Nov 06 '15 at 19:01
  • Now that is way more close. In the meantime I got some advice to use Spring Boot Actuator. I do not have that possibility, so I went on looking in the source of Spring Boot Actuator and saw this file: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/RequestMappingEndpoint.java. I'm going test that in my application. Thanks for the advice! I will edit my post once I have an answer ready. – Jack Sierkstra Nov 06 '15 at 19:12
  • Cool! All the best Jack! – James Jithin Nov 06 '15 at 19:27
  • 1
    @JackSierkstra If you get the answer you can post it as an answer and accept it. – Kannan Ramamoorthy Jun 17 '17 at 16:48
  • can you check the link below. https://stackoverflow.com/questions/32525699/listing-all-deployed-rest-endpoints-spring-boot-jersey/35237151#35237151 – Cahit Yiğit Çetiner Jul 29 '19 at 10:45
  • Check out this thread: https://stackoverflow.com/questions/43541080/how-to-get-all-endpoints-list-after-startup-spring-boot/59165297 – Thomas Verhoeven Jan 20 '21 at 09:59

1 Answers1

0

I assume based on how the questions is worded that you are not using Spring Boot, if you were, the actuator mappings endpoint does this for you, but your answer lies in how the mappings endpoint is build in actuator. There is a RequestMappingHandlerMapping object you leverage.

fpmoles
  • 1,196
  • 7
  • 14