Skip to content

Instantly share code, notes, and snippets.

@crmaxx
Forked from itang/undertow.scala
Last active January 4, 2019 13:47
Show Gist options
  • Save crmaxx/d72ae5e80407fb64e8b4 to your computer and use it in GitHub Desktop.
Save crmaxx/d72ae5e80407fb64e8b4 to your computer and use it in GitHub Desktop.
import io.undertow.Undertow
import io.undertow.server.HttpHandler
import io.undertow.server.HttpServerExchange
import io.undertow.util.Headers
object server extends App {
val server: Undertow = Undertow.builder().addHttpListener(8080, "localhost").setHandler(new HttpHandler() {
override def handleRequest(exchange: HttpServerExchange): Unit = {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain")
exchange.getResponseSender().send("Hello, world!")
}
}).build()
server.start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment