Search in sources :

Example 1 with HttpServerRequest

use of reactor.ipc.netty.http.server.HttpServerRequest in project spring-framework by spring-projects.

the class ReactorHttpHandlerAdapter method apply.

@Override
public Mono<Void> apply(HttpServerRequest request, HttpServerResponse response) {
    NettyDataBufferFactory bufferFactory = new NettyDataBufferFactory(response.alloc());
    ReactorServerHttpRequest req = new ReactorServerHttpRequest(request, bufferFactory);
    ReactorServerHttpResponse resp = new ReactorServerHttpResponse(response, bufferFactory);
    return this.httpHandler.handle(req, resp).otherwise(ex -> {
        logger.error("Could not complete request", ex);
        response.status(HttpResponseStatus.INTERNAL_SERVER_ERROR);
        return Mono.empty();
    }).doOnSuccess(aVoid -> logger.debug("Successfully completed request"));
}
Also used : HttpServerRequest(reactor.ipc.netty.http.server.HttpServerRequest) NettyDataBufferFactory(org.springframework.core.io.buffer.NettyDataBufferFactory) BiFunction(java.util.function.BiFunction) HttpResponseStatus(io.netty.handler.codec.http.HttpResponseStatus) Mono(reactor.core.publisher.Mono) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) HttpServerResponse(reactor.ipc.netty.http.server.HttpServerResponse) Assert(org.springframework.util.Assert) NettyDataBufferFactory(org.springframework.core.io.buffer.NettyDataBufferFactory)

Aggregations

HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)1 BiFunction (java.util.function.BiFunction)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 NettyDataBufferFactory (org.springframework.core.io.buffer.NettyDataBufferFactory)1 Assert (org.springframework.util.Assert)1 Mono (reactor.core.publisher.Mono)1 HttpServerRequest (reactor.ipc.netty.http.server.HttpServerRequest)1 HttpServerResponse (reactor.ipc.netty.http.server.HttpServerResponse)1