-
-
Save darkfrog26/ce90a08a8bd58e674e7faed84d021db8 to your computer and use it in GitHub Desktop.
This file contains 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 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