Created
July 25, 2015 15:10
-
-
Save csainty/87ac74993389251736d1 to your computer and use it in GitHub Desktop.
Undertow Hello World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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