use of reactor.ipc.netty.http.server.HttpServer 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();
}
use of reactor.ipc.netty.http.server.HttpServer 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();
}
use of reactor.ipc.netty.http.server.HttpServer in project reactor-netty by reactor.
the class TcpServerTests method proxyTest.
@Test
@Ignore
public void proxyTest() throws Exception {
HttpServer server = HttpServer.create();
server.newRouter(r -> r.get("/search/{search}", (in, out) -> HttpClient.create().get("foaas.herokuapp.com/life/" + in.param("search")).flatMapMany(repliesOut -> out.send(repliesOut.receive())))).block(Duration.ofSeconds(30)).onClose().block(Duration.ofSeconds(30));
}
use of reactor.ipc.netty.http.server.HttpServer in project reactor-netty by reactor.
the class TcpServerTests method wsTest.
@Test
@Ignore
public void wsTest() throws Exception {
HttpServer server = HttpServer.create();
server.newRouter(r -> r.get("/search/{search}", (in, out) -> HttpClient.create().get("ws://localhost:3000", requestOut -> requestOut.sendWebsocket().sendString(Mono.just("ping"))).flatMapMany(repliesOut -> out.sendGroups(repliesOut.receive().window(100))))).block(Duration.ofSeconds(30)).onClose().block(Duration.ofSeconds(30));
}
use of reactor.ipc.netty.http.server.HttpServer in project reactor-netty by reactor.
the class TcpServerTests method testHang.
@Test(timeout = 10000)
public void testHang() throws Exception {
NettyContext httpServer = HttpServer.create(opts -> opts.host("0.0.0.0").port(0)).newRouter(r -> r.get("/data", (request, response) -> {
return response.send(Mono.empty());
})).block(Duration.ofSeconds(30));
httpServer.dispose();
}
Aggregations