Skip to content

Instantly share code, notes, and snippets.

@darkfrog26
Created May 18, 2016 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darkfrog26/ce90a08a8bd58e674e7faed84d021db8 to your computer and use it in GitHub Desktop.
Save darkfrog26/ce90a08a8bd58e674e7faed84d021db8 to your computer and use it in GitHub Desktop.
import java.net.URI
import io.undertow.server.handlers.proxy.SimpleProxyClientProvider
import io.undertow.{Handlers, Undertow}
import io.undertow.server.{HttpHandler, HttpServerExchange}
import io.undertow.util.Headers
object TestUndertow extends App {
val proxyClient = new SimpleProxyClientProvider(new URI("http://hyperscala.org"))
val proxy = Handlers.proxyHandler(proxyClient)
val mutator = new HttpHandler {
override def handleRequest(exchange: HttpServerExchange): Unit = {
exchange.getRequestHeaders.put(Headers.HOST, "hyperscala.org")
proxy.handleRequest(exchange)
}
}
val server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(mutator)
.build()
server.start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment