use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = HttpServer.create().host(// <1>
"localhost").port(// <2>
8080).bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class CustomForwardedHeaderHandlerApplication method main.
public static void main(String[] args) {
DisposableServer server = HttpServer.create().forwarded((connectionInfo, request) -> {
// <1>
String hostHeader = request.headers().get("X-Forwarded-Host");
if (hostHeader != null) {
String[] hosts = hostHeader.split(",", 2);
InetSocketAddress hostAddress = AddressUtils.createUnresolved(hosts[hosts.length - 1].trim(), connectionInfo.getHostAddress().getPort());
connectionInfo = connectionInfo.withHostAddress(hostAddress);
}
return connectionInfo;
}).route(routes -> routes.get("/clientip", (request, response) -> response.sendString(Mono.just(// <2>
request.remoteAddress().getHostString())))).bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = // <1>
TcpServer.create().bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = TcpServer.create().doOnConnection(conn -> conn.addHandler(new ReadTimeoutHandler(10, TimeUnit.SECONDS))).doOnChannelInit((observer, channel, remoteAddress) -> channel.pipeline().addFirst(// <2>
new LoggingHandler("reactor.netty.examples"))).bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
File cert = new File("certificate.crt");
File key = new File("private.key");
TcpSslContextSpec tcpSslContextSpec = TcpSslContextSpec.forServer(cert, key);
DisposableServer server = TcpServer.create().secure(spec -> spec.sslContext(tcpSslContextSpec)).bindNow();
server.onDispose().block();
}
Aggregations