Search in sources :

Example 1 with ReactorHttpHandlerAdapter

use of org.springframework.http.server.reactive.ReactorHttpHandlerAdapter in project tutorials by eugenp.

the class SpringSecurity5Application method nettyContext.

@Bean
public NettyContext nettyContext(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create("localhost", 8080);
    return httpServer.newHandler(adapter).block();
}
Also used : HttpHandler(org.springframework.http.server.reactive.HttpHandler) HttpServer(reactor.ipc.netty.http.server.HttpServer) ReactorHttpHandlerAdapter(org.springframework.http.server.reactive.ReactorHttpHandlerAdapter) Bean(org.springframework.context.annotation.Bean)

Example 2 with ReactorHttpHandlerAdapter

use of org.springframework.http.server.reactive.ReactorHttpHandlerAdapter in project tutorials by eugenp.

the class Spring5ReactiveServerClientIntegrationTest method setUp.

@BeforeAll
public static void setUp() throws Exception {
    HttpServer server = HttpServer.create("localhost", 8080);
    RouterFunction<?> route = RouterFunctions.route(POST("/task/process"), request -> ServerResponse.ok().body(request.bodyToFlux(Task.class).map(ll -> new Task("TaskName", 1)), Task.class)).and(RouterFunctions.route(GET("/task"), request -> ServerResponse.ok().body(Mono.just("server is alive"), String.class)));
    HttpHandler httpHandler = RouterFunctions.toHttpHandler(route);
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler);
    nettyContext = server.newHandler(adapter).block();
}
Also used : ReactorHttpHandlerAdapter(org.springframework.http.server.reactive.ReactorHttpHandlerAdapter) RouterFunctions(org.springframework.web.reactive.function.server.RouterFunctions) POST(org.springframework.web.reactive.function.server.RequestPredicates.POST) Mono(reactor.core.publisher.Mono) AfterAll(org.junit.jupiter.api.AfterAll) Flux(reactor.core.publisher.Flux) HttpHandler(org.springframework.http.server.reactive.HttpHandler) BeforeAll(org.junit.jupiter.api.BeforeAll) RouterFunction(org.springframework.web.reactive.function.server.RouterFunction) ServerResponse(org.springframework.web.reactive.function.server.ServerResponse) Duration(java.time.Duration) Task(com.baeldung.web.reactive.Task) NettyContext(reactor.ipc.netty.NettyContext) GET(org.springframework.web.reactive.function.server.RequestPredicates.GET) HttpServer(reactor.ipc.netty.http.server.HttpServer) HttpHandler(org.springframework.http.server.reactive.HttpHandler) Task(com.baeldung.web.reactive.Task) HttpServer(reactor.ipc.netty.http.server.HttpServer) ReactorHttpHandlerAdapter(org.springframework.http.server.reactive.ReactorHttpHandlerAdapter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with ReactorHttpHandlerAdapter

use of org.springframework.http.server.reactive.ReactorHttpHandlerAdapter in project spring-boot by spring-projects.

the class NettyReactiveWebServerFactory method getWebServer.

@Override
public WebServer getWebServer(HttpHandler httpHandler) {
    HttpServer server = createHttpServer();
    ReactorHttpHandlerAdapter handlerAdapter = new ReactorHttpHandlerAdapter(httpHandler);
    return new NettyWebServer(server, handlerAdapter);
}
Also used : HttpServer(reactor.ipc.netty.http.server.HttpServer) ReactorHttpHandlerAdapter(org.springframework.http.server.reactive.ReactorHttpHandlerAdapter)

Aggregations

ReactorHttpHandlerAdapter (org.springframework.http.server.reactive.ReactorHttpHandlerAdapter)3 HttpServer (reactor.ipc.netty.http.server.HttpServer)3 HttpHandler (org.springframework.http.server.reactive.HttpHandler)2 Task (com.baeldung.web.reactive.Task)1 Duration (java.time.Duration)1 AfterAll (org.junit.jupiter.api.AfterAll)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 Bean (org.springframework.context.annotation.Bean)1 GET (org.springframework.web.reactive.function.server.RequestPredicates.GET)1 POST (org.springframework.web.reactive.function.server.RequestPredicates.POST)1 RouterFunction (org.springframework.web.reactive.function.server.RouterFunction)1 RouterFunctions (org.springframework.web.reactive.function.server.RouterFunctions)1 ServerResponse (org.springframework.web.reactive.function.server.ServerResponse)1 Flux (reactor.core.publisher.Flux)1 Mono (reactor.core.publisher.Mono)1 NettyContext (reactor.ipc.netty.NettyContext)1