Search in sources :

Example 11 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().httpFormDecoder(// <1>
    builder -> builder.maxInMemorySize(0)).route(routes -> routes.post("/multipart", (request, response) -> response.sendString(// <2>
    request.receiveForm(builder -> builder.maxInMemorySize(256)).flatMap(data -> Mono.just('[' + data.getName() + ']'))))).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)

Example 12 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("/{param}", (request, response) -> {
        if (request.requestHeaders().contains("Some-Header")) {
            return response.sendString(Mono.just(request.param("param")));
        }
        return response.sendNotFound();
    })).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)

Example 13 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) -> response.sendString(Mono.just("hello"))).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)

Example 14 with DisposableServer

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

the class Application method main.

public static void main(String[] args) throws Exception {
    File defaultCert = new File("default_certificate.crt");
    File defaultKey = new File("default_private.key");
    File testDomainCert = new File("default_certificate.crt");
    File testDomainKey = new File("default_private.key");
    SslContext defaultSslContext = SslContextBuilder.forServer(defaultCert, defaultKey).build();
    SslContext testDomainSslContext = SslContextBuilder.forServer(testDomainCert, testDomainKey).build();
    DisposableServer server = HttpServer.create().secure(spec -> spec.sslContext(defaultSslContext).addSniMapping("*.test.com", testDomainSpec -> testDomainSpec.sslContext(testDomainSslContext))).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) SslContext(io.netty.handler.ssl.SslContext) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) DisposableServer(reactor.netty.DisposableServer) File(java.io.File) DisposableServer(reactor.netty.DisposableServer) File(java.io.File) SslContext(io.netty.handler.ssl.SslContext)

Example 15 with DisposableServer

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

the class CustomLogAccessFormatApplication method main.

public static void main(String[] args) {
    DisposableServer server = HttpServer.create().accessLog(true, x -> AccessLog.create("method={}, uri={}", x.method(), x.uri())).bindNow();
    server.onDispose().block();
}
Also used : HttpServer(reactor.netty.http.server.HttpServer) DisposableServer(reactor.netty.DisposableServer) AccessLog(reactor.netty.http.server.logging.AccessLog) 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