Search in sources :

Example 21 with DisposableServer

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

the class Application method main.

public static void main(String[] args) {
    // <1>
    Metrics.globalRegistry.config().meterFilter(MeterFilter.maximumAllowableTags("reactor.netty.http.server", "URI", 100, MeterFilter.deny()));
    DisposableServer server = HttpServer.create().metrics(true, s -> {
        if (s.startsWith("/stream/")) {
            // <2>
            return "/stream/{n}";
        } else if (s.startsWith("/bytes/")) {
            return "/bytes/{n}";
        }
        return s;
    }).route(r -> r.get("/stream/{n}", (req, res) -> res.sendString(Mono.just(req.param("n")))).get("/bytes/{n}", (req, res) -> res.sendString(Mono.just(req.param("n"))))).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) MeterFilter(io.micrometer.api.instrument.config.MeterFilter) Metrics(io.micrometer.api.instrument.Metrics) Mono(reactor.core.publisher.Mono) DisposableServer(reactor.netty.DisposableServer) DisposableServer(reactor.netty.DisposableServer)

Example 22 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().handle(// <1>
    (request, response) -> request.receive().then()).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) DisposableServer(reactor.netty.DisposableServer) DisposableServer(reactor.netty.DisposableServer)

Example 23 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().route(routes -> routes.get("/hello", (request, response) -> response.status(HttpResponseStatus.OK).header(HttpHeaderNames.CONTENT_LENGTH, "12").sendString(Mono.just("Hello World!")))).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) Mono(reactor.core.publisher.Mono) HttpHeaderNames(io.netty.handler.codec.http.HttpHeaderNames) DisposableServer(reactor.netty.DisposableServer) DisposableServer(reactor.netty.DisposableServer)

Example 24 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 = TcpServer.create().host(// <1>
    "localhost").port(// <2>
    8080).bindNow();
    server.onDispose().block();
}
Also used : DisposableServer(reactor.netty.DisposableServer)

Example 25 with DisposableServer

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

the class MultiAddressApplication method main.

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

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