use of org.springframework.http.server.reactive.HttpHandler in project spring-boot by spring-projects.
the class HttpHandlerAutoConfigurationTests method shouldConfigureWebFiltersFunctional.
@Test
public void shouldConfigureWebFiltersFunctional() {
load(FunctionalConfigWithWebFilters.class);
assertThat(this.context.getBeansOfType(HttpHandler.class).size()).isEqualTo(1);
HttpHandler handler = this.context.getBean(HttpHandler.class);
assertThat(handler).isInstanceOf(WebHandler.class);
WebHandler webHandler = (WebHandler) handler;
while (webHandler instanceof WebHandlerDecorator) {
if (webHandler instanceof FilteringWebHandler) {
FilteringWebHandler filteringWebHandler = (FilteringWebHandler) webHandler;
assertThat(filteringWebHandler.getFilters()).containsExactly(this.context.getBean("customWebFilter", WebFilter.class));
return;
}
webHandler = ((WebHandlerDecorator) webHandler).getDelegate();
}
fail("Did not find any FilteringWebHandler");
}
use of org.springframework.http.server.reactive.HttpHandler in project tutorials by eugenp.
the class FunctionalWebApplication method start.
WebServer start() throws Exception {
WebHandler webHandler = (WebHandler) toHttpHandler(routingFunction());
HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(webHandler).filter(new IndexRewriteFilter()).build();
Tomcat tomcat = new Tomcat();
tomcat.setHostname("localhost");
tomcat.setPort(9090);
Context rootContext = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
rootContext.addServletMappingDecoded("/", "httpHandlerServlet");
TomcatWebServer server = new TomcatWebServer(tomcat);
server.start();
return server;
}
use of org.springframework.http.server.reactive.HttpHandler in project tutorials by eugenp.
the class ExploreSpring5URLPatternUsingRouterFunctions method start.
WebServer start() throws Exception {
WebHandler webHandler = (WebHandler) toHttpHandler(routingFunction());
HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(webHandler).filter(new IndexRewriteFilter()).build();
Tomcat tomcat = new Tomcat();
tomcat.setHostname("localhost");
tomcat.setPort(9090);
Context rootContext = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
rootContext.addServletMappingDecoded("/", "httpHandlerServlet");
TomcatWebServer server = new TomcatWebServer(tomcat);
server.start();
return server;
}
use of org.springframework.http.server.reactive.HttpHandler in project tutorials by eugenp.
the class FunctionalWebApplication method start.
WebServer start() throws Exception {
WebHandler webHandler = (WebHandler) toHttpHandler(routingFunction());
HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(webHandler).filter(new IndexRewriteFilter()).build();
Tomcat tomcat = new Tomcat();
tomcat.setHostname("localhost");
tomcat.setPort(9090);
Context rootContext = tomcat.addContext("", System.getProperty("java.io.tmpdir"));
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
rootContext.addServletMappingDecoded("/", "httpHandlerServlet");
TomcatWebServer server = new TomcatWebServer(tomcat);
server.start();
return server;
}
use of org.springframework.http.server.reactive.HttpHandler in project spring-framework by spring-projects.
the class HttpServerTests method start.
@BeforeEach
public void start() throws Exception {
HttpHandler httpHandler = RouterFunctions.toHttpHandler(route(GET("/test"), request -> ServerResponse.ok().bodyValue("It works!")));
this.server = new ReactorHttpServer();
this.server.setHandler(httpHandler);
this.server.afterPropertiesSet();
this.server.start();
this.client = WebTestClient.bindToServer().baseUrl("http://localhost:" + this.server.getPort()).build();
}
Aggregations