In java spark web framework a route is defined as
get("/", (request, response) -> {
// Show something
});
In my application I define multiple routes. Is there any way I can get all the exposed routes of the application?
{ // Show something }); In my application I define multiple routes. " /> { // Show something }); In my application I define multiple routes. " /> { // Show something }); In my application I define multiple routes. "/>
In java spark web framework a route is defined as
get("/", (request, response) -> {
// Show something
});
In my application I define multiple routes. Is there any way I can get all the exposed routes of the application?
On
It's possible now in spark 2.9.4
import spark.Spark;
import spark.routematch.RouteMatch;
// somewhere after route definitions
for (RouteMatch route : routes()) {
String method = route.getHttpMethod().toString();
if (method.equals("before") || method.equals("after")) continue;
System.out.printf("--> %-7s %s\n", method.toUpperCase(), route.getMatchUri());
}
output
--> POST /internal/update_notification
--> GET /internal/history
--> GET /internal/history_details
--> GET /ping
As far as I know, there's no way to automatically find REST routes as they do not have a standard registry service. Although, you can document them using Swagger or even store them using chrome applications such as Postman or Advanced Rest Client.