Search in sources :

Example 51 with DisposableServer

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().accessLog(true).bindNow();
    server.onDispose().block();
}
Also used : DisposableServer(reactor.netty.DisposableServer)

Example 52 with DisposableServer

use of reactor.netty.DisposableServer in project reactor-netty by reactor.

the class CustomFormatAndFilterAccessLogApplication method main.

public static void main(String[] args) {
    DisposableServer server = HttpServer.create().accessLog(true, // <1>
    AccessLogFactory.createFilter(// <1>
    p -> !String.valueOf(p.uri()).startsWith("/health/"), // <2>
    x -> AccessLog.create("method={}, uri={}", x.method(), x.uri()))).bindNow();
    server.onDispose().block();
}
Also used : DisposableServer(reactor.netty.DisposableServer)

Example 53 with DisposableServer

use of reactor.netty.DisposableServer in project reactor-netty by reactor.

the class FilterLogAccessApplication method main.

public static void main(String[] args) {
    DisposableServer server = HttpServer.create().accessLog(true, AccessLogFactory.createFilter(p -> !String.valueOf(p.uri()).startsWith("/health/"))).bindNow();
    server.onDispose().block();
}
Also used : DisposableServer(reactor.netty.DisposableServer)

Example 54 with DisposableServer

use of reactor.netty.DisposableServer in project reactor-netty by reactor.

the class MultiAddressApplication method main.

public static void main(String[] args) {
    HttpServer httpServer = HttpServer.create();
    DisposableServer server1 = httpServer.host(// <1>
    "localhost").port(// <2>
    8080).bindNow();
    DisposableServer server2 = httpServer.host(// <3>
    "0.0.0.0").port(// <4>
    8081).bindNow();
    Mono.when(server1.onDispose(), server2.onDispose()).block();
}
Also used : DisposableServer(reactor.netty.DisposableServer) HttpServer(reactor.netty.http.server.HttpServer)

Example 55 with DisposableServer

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().forwarded(// <1>
    true).route(routes -> routes.get("/clientip", (request, response) -> response.sendString(Mono.just(// <2>
    request.remoteAddress().getHostString())))).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) Mono(reactor.core.publisher.Mono) DisposableServer(reactor.netty.DisposableServer) DisposableServer(reactor.netty.DisposableServer)

Aggregations

DisposableServer (reactor.netty.DisposableServer)137 Mono (reactor.core.publisher.Mono)84 Test (org.junit.jupiter.api.Test)79 Duration (java.time.Duration)71 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)71 AtomicReference (java.util.concurrent.atomic.AtomicReference)68 Flux (reactor.core.publisher.Flux)68 Connection (reactor.netty.Connection)67 TimeUnit (java.util.concurrent.TimeUnit)65 LoopResources (reactor.netty.resources.LoopResources)60 List (java.util.List)58 CountDownLatch (java.util.concurrent.CountDownLatch)57 DomainSocketAddress (io.netty.channel.unix.DomainSocketAddress)56 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)55 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)54 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)54 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)53 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)53 Assumptions.assumeThat (org.assertj.core.api.Assumptions.assumeThat)53 StepVerifier (reactor.test.StepVerifier)53