heaphach heaphach - 4 months ago 119x
Java Question

Dropwizard : New admin resource

I'm using Drowpizard 0.7.1, but perhaps I will upgrade to 0.8.4 very soon.

Does anyone know how to add a admin resource to dropwizard, that is shown in Operational Menu like the example below?

Operational Menu



I don't think you can do this easily.

The AdminServlet is created when the ServerFactory is built. It may be possible to extend DefaultServerFactory and override createAdminServlet to create a custom Admin servlet with your links etc... (You would then have to set your server factory via configuration.)

It seems like this would involve some duplication of code and could be quite fragile.

It might be easier to just register your own admin servlet (in addition to the regular one), e.g.:

environment.admin().addServlet("custom-admin", new CustomAdminServlet())

Probably not ideal either.