Hi,
I would like to programatic create the API resources as in
https://jersey.java.net/documentation/latest/resource-builder.htmlI'm using DW 0.8.4.
but it does not get registered? I have try with both
environment.jersey().register() and environment.jersey().getResourceConfig().registerResources
This is my simple code:
@Override
public void run(ApplicationConfiguration applicationConfiguration, Environment environment) throws Exception {
Resource.Builder resourceBuilder = Resource.builder();
resourceBuilder.path("helloworld");
ResourceMethod.Builder methodBuilder = resourceBuilder.addMethod("GET");
methodBuilder.produces(MediaType.APPLICATION_JSON).handledBy(new Inflector<ContainerRequestContext, Object>() {
@Override
public Object apply(ContainerRequestContext containerRequestContext) {
return "HELLO";
}
});
//environment.jersey().register(resourceBuilder.build());
environment.jersey().getResourceConfig().registerResources(resourceBuilder.build());
}
This is th eoutput when I start DW:
INFO [2015-09-30 11:31:08,757] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
NONE
INFO [2015-09-30 11:31:08,759] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@585c13de{/,null,AVAILABLE}
INFO [2015-09-30 11:31:08,781] io.dropwizard.setup.AdminEnvironment: tasks =
POST /tasks/log-level (io.dropwizard.servlets.tasks.LogConfigurationTask)
POST /tasks/gc (io.dropwizard.servlets.tasks.GarbageCollectionTask)