JAX-RS server handler for Netty 4.1 using Jersey.
Create resource endpoint:
@Path("/")
public class EchoResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response echo() {
return Response.ok()
.entity("Hello, World!")
.build();
}
}
Setup Jersey Application:
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
setApplicationName("test");
register(JacksonFeature.class);
register(LoggingFeature.class);
register(MultiPartFeature.class);
// endpoints
register(EchoResource.class);
}
}
Start netty server:
JaxrsNettyServer server = new JaxrsNettyServer(
"localhost", 8080,
new JerseyConfig()
);
server.start();
See integration tests for more examples.