Dropwizard : New admin resource

前端 未结 2 717
后悔当初
后悔当初 2021-02-20 09:53

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

2条回答
  •  名媛妹妹
    2021-02-20 10:16

    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())
        .addMapping("/custom-admin");
    

    Probably not ideal either.

提交回复
热议问题