title: spring webflux: purely functional way to attach websocket adapter to reactor-netty server
body: <p>I am not able to figure out a way to attach a WebSocketHandlerAdapter to a reactor netty server.</p>
  
  <p>Requirements: 
  I want to start a reactor netty server and attach http (REST) endpoints and websocket endpoints to the same server.  I have gone through the documentation and some sample demo application mentioned in the documentation.  They show how to attach a HttpHandlerAdapter to the the HttpServer using newHandler() function.  But when it comes to websockets they switch back to using spring boot and annotation examples.  I am not able to find how to attach websockets using functional endpoints.</p>
  
  <p>Please point me in the right direction on how to implement this.
  1. how do I attach the websocket adapter to the netty server?
  2. Should I use HttpServer or TcpServer?</p>
  
  <p>Note:
  1. I am not using spring boot.
  2. I am not using annotations.
  3. Trying to achieve this only using functional webflux end points.</p>
  
  <p>Sample code:</p>
  
  <pre><code>public HandlerMapping webSocketMapping() 
  {
    Map&lt;String, WebSocketHandler&gt; map = new HashMap&lt;&gt;();
    map.put("/echo", new EchoTestingWebSocketHandler());
    SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
    mapping.setUrlMap(map);
    mapping.setOrder(-1);
    return mapping;
  }
  public WebSocketHandlerAdapter wsAdapter() 
  {
    HandshakeWebSocketService wsService = new HandshakeWebSocketService(new ReactorNettyRequestUpgradeStrategy());
    return new WebSocketHandlerAdapter(wsService);
  }
  
    protected void startServer(String host, int port) 
    {
      HttpServer server = HttpServer.create(host, port);
      server.newHandler(wsAdapter()).block();    //how do I attach the websocket adapter to the netty server
    }
  </code></pre>