Skip to content

Instantly share code, notes, and snippets.

@csainty
Created July 25, 2015 15:10
Show Gist options
  • Save csainty/87ac74993389251736d1 to your computer and use it in GitHub Desktop.
Save csainty/87ac74993389251736d1 to your computer and use it in GitHub Desktop.
Undertow Hello World
import io.undertow.Undertow;
import io.undertow.util.Headers;
public class HelloServer {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8081, "localhost")
.setHandler((exchange) -> {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}).build();
System.out.println("Server listening on http://localhost:8081");
server.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment