WildFly Management - List / detect REST endpoints deployed in WildFly

Is there a way (e.g. from the WildFly management console) to display all the REST endpoints deployed in WildFly? Or list them in the log when the server starts?

+6
source share
1 answer

Using RegistryStatsResource

With RESTEasy (supplied with WildFly) you can add the following to web.xml :

 <context-param> <param-name>resteasy.resources</param-name> <param-value>org.jboss.resteasy.plugins.stats.RegistryStatsResource</param-value> </context-param> 

And then request the following url:

 http://[hostname]:[port]/[context]/[api-path]/resteasy/registry 

Such an endpoint can create XML and JSON content. Just add the Accept header to the request with the desired media type:

  • application/xml
  • application/json

Source code verification

If you're interested in source code to create your own implementation, check out the RegistryStatsResource class in GitHub .

Below is the most significant part of the source code (it is specific to RESTEasy):

 ResourceMethodRegistry registry = (ResourceMethodRegistry) ResteasyProviderFactory.getContextData(Registry.class); for (String key : registry.getBounded().keySet()){ List<ResourceInvoker> invokers = registry.getBounded().get(key); for (ResourceInvoker invoker : invokers) { if (invoker instanceof ResourceMethodInvoker) { ResourceMethodInvoker rm = (ResourceMethodInvoker) invoker; // Extract metadata from the ResourceMethodInvoker } } 

Swagger may be an alternative

Depending on your requirements, you can use Swagger to document your API. It comes with a set of annotations to describe your REST endpoints.

Then use the Swagger UI to provide live documentation for your API.


Note: As of February 2017, it looks like the RegistryStatsResource class is completely undocumented. Sometimes I discovered this when I was digging into the RESTEasy source code for debugging purposes. Also, I found this JBoss EAP issue that tracks missing documentation for this class.

+5
source

All Articles