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))); }