Search in sources :

Example 16 with Endpoint

use of com.nike.riposte.server.http.Endpoint in project riposte by Nike-Inc.

the class RoutingHandler method doChannelRead.

@Override
public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) {
    if (msg instanceof HttpRequest) {
        HttpRequest nettyRequest = (HttpRequest) msg;
        HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get();
        RequestInfo request = handlerUtils.createRequestInfoFromNettyHttpRequestAndHandleStateSetupIfNecessary(nettyRequest, state);
        // If the Netty HttpRequest is invalid, we shouldn't do any endpoint routing.
        handlerUtils.throwExceptionIfNotSuccessfullyDecoded(nettyRequest);
        // The HttpRequest is valid, so continue with the endpoint routing.
        Pair<Endpoint<?>, String> endpointForExecution = findSingleEndpointForExecution(request);
        request.setPathParamsBasedOnPathTemplate(endpointForExecution.getRight());
        state.setEndpointForExecution(endpointForExecution.getLeft(), endpointForExecution.getRight());
        handleSpanNameUpdateForRequestWithPathTemplate(nettyRequest, request, state);
        throwExceptionIfContentLengthHeaderIsLargerThanConfiguredMaxRequestSize(nettyRequest, endpointForExecution.getLeft());
    }
    return PipelineContinuationBehavior.CONTINUE;
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) Endpoint(com.nike.riposte.server.http.Endpoint) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) RequestInfo(com.nike.riposte.server.http.RequestInfo)

Aggregations

Endpoint (com.nike.riposte.server.http.Endpoint)16 Test (org.junit.Test)12 StandardEndpoint (com.nike.riposte.server.http.StandardEndpoint)9 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)6 RequestInfo (com.nike.riposte.server.http.RequestInfo)6 Timer (com.codahale.metrics.Timer)5 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)5 HttpMethod (io.netty.handler.codec.http.HttpMethod)5 Meter (com.codahale.metrics.Meter)4 ServerConfig (com.nike.riposte.server.config.ServerConfig)4 Histogram (com.codahale.metrics.Histogram)3 MetricRegistry (com.codahale.metrics.MetricRegistry)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Executor (java.util.concurrent.Executor)3 NotNull (org.jetbrains.annotations.NotNull)3 Before (org.junit.Before)3