Example usage for org.springframework.http.server.reactive ServletHttpHandlerAdapter ServletHttpHandlerAdapter

List of usage examples for org.springframework.http.server.reactive ServletHttpHandlerAdapter ServletHttpHandlerAdapter

Introduction

In this page you can find the example usage for org.springframework.http.server.reactive ServletHttpHandlerAdapter ServletHttpHandlerAdapter.

Prototype

public ServletHttpHandlerAdapter(HttpHandler httpHandler) 

Source Link

Usage

From source file:top.zhacker.ms.reactor.spring.function.Server.java

public void startTomcatServer() throws LifecycleException {
    RouterFunction<?> route = routingFunction();
    HttpHandler httpHandler = toHttpHandler(route);

    Tomcat tomcatServer = new Tomcat();
    tomcatServer.setHostname(HOST);/*ww  w .j  a va  2  s .  c  o  m*/
    tomcatServer.setPort(PORT);
    Context rootContext = tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
    ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler);
    Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet);
    rootContext.addServletMapping("/", "httpHandlerServlet");
    tomcatServer.start();
}