I'm just discovering how Undertow works and I was surprised by its api:
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(new HttpHandler() {
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
Is there a way to use the more convenient servlet api like this somehow?
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(new HttpHandler() {
@Override
public void handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
// ...
}
}).build();
server.start();
What I'm trying to achieve is to replace the currently working Jetty container which uses the servlet api by Undertow but after reading the docs and the source I can't seem to find a way to do so. I'm not using .war files just an embedded Jetty. Do someone has any pointers?