All Downloads are FREE. Search and download functionalities are using the official Maven repository.

netflix.karyon.transport.http.HttpRequestHandler Maven / Gradle / Ivy

There is a newer version: 2.9.2
Show newest version
package netflix.karyon.transport.http;

import io.reactivex.netty.protocol.http.server.HttpServerRequest;
import io.reactivex.netty.protocol.http.server.HttpServerResponse;
import io.reactivex.netty.protocol.http.server.RequestHandler;
import netflix.karyon.transport.interceptor.AbstractInterceptorSupport;
import netflix.karyon.transport.interceptor.InterceptorExecutor;
import rx.Observable;

/**
 * An implementation of {@link RequestHandler} for karyon.
 *
 * @author Nitesh Kant
 */
public class HttpRequestHandler implements RequestHandler {

    private final InterceptorExecutor, HttpServerResponse, HttpKeyEvaluationContext> executor;

    public HttpRequestHandler(RequestHandler router) {
        this(router, new HttpInterceptorSupport());
    }

    public HttpRequestHandler(RequestHandler router,
                              AbstractInterceptorSupport, HttpServerResponse, HttpKeyEvaluationContext, ?, ?> interceptorSupport) {
        executor = new InterceptorExecutor, HttpServerResponse, HttpKeyEvaluationContext>(interceptorSupport, router);
    }

    @Override
    public Observable handle(HttpServerRequest request, HttpServerResponse response) {
        return executor.execute(request, response, new HttpKeyEvaluationContext(response.getChannel()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy