private String getPathWithinApplication(ServerHttpRequest request) {
   String contextPath = request.getContextPath();
   String path = request.getURI().getRawPath();
   if (!StringUtils.hasText(contextPath)) {
     return path;
   }
   int contextLength = contextPath.length();
   return (path.length() > contextLength ? path.substring(contextLength) : "");
 }
  private Object createHttpEntity(
      Object body, ResolvableType entityType, ServerWebExchange exchange) {

    ServerHttpRequest request = exchange.getRequest();
    HttpHeaders headers = request.getHeaders();
    if (RequestEntity.class == entityType.getRawClass()) {
      return new RequestEntity<>(body, headers, request.getMethod(), request.getURI());
    } else {
      return new HttpEntity<>(body, headers);
    }
  }
 @Override
 public Mono<Void> handle(ServerWebExchange exchange) {
   if (logger.isDebugEnabled()) {
     ServerHttpRequest request = exchange.getRequest();
     logger.debug("Processing " + request.getMethod() + " request for [" + request.getURI() + "]");
   }
   return Flux.fromIterable(this.handlerMappings)
       .concatMap(mapping -> mapping.getHandler(exchange))
       .next()
       .then(handler -> invokeHandler(exchange, handler))
       .then(result -> handleResult(exchange, result))
       .otherwise(ex -> Mono.error(this.errorMapper.apply(ex)));
 }
  public RxNettyWebSocketHandlerAdapter(
      ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler) {

    Assert.notNull("'request' is required");
    Assert.notNull("'response' is required");
    Assert.notNull("'handler' handler is required");

    this.uri = request.getURI();
    this.bufferFactory = (NettyDataBufferFactory) response.bufferFactory();
    this.handler = handler;
  }
 private static MediaType contentType(ServerHttpRequest request) {
   MediaType result = request.getHeaders().getContentType();
   return result != null ? result : MediaType.APPLICATION_OCTET_STREAM;
 }