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

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

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

import io.netty.handler.codec.http.HttpMethod;
import io.reactivex.netty.protocol.http.server.HttpServerRequest;
import io.reactivex.netty.protocol.http.server.RequestHandler;
import netflix.karyon.transport.interceptor.InterceptorKey;

/**
 * A convenience builder to create {@link HttpRequestHandler} instances.
 *
 * @author Nitesh Kant
 */
public class HttpRequestHandlerBuilder {

    private final HttpInterceptorSupport interceptorSupport;
    private final RequestHandler router;

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

    public HttpRequestHandlerBuilder(HttpInterceptorSupport interceptorSupport,
                                     RequestHandler router) {
        this.interceptorSupport = interceptorSupport;
        this.router = router;
    }

    public HttpInterceptorSupport.HttpAttacher forKey(InterceptorKey, HttpKeyEvaluationContext> key) {
        return interceptorSupport.forKey(key);
    }

    public HttpInterceptorSupport.HttpAttacher forUri(String uri) {
        return interceptorSupport.forUri(uri);
    }

    public HttpInterceptorSupport.HttpAttacher forUriRegex(String uriRegEx) {
        return interceptorSupport.forUriRegex(uriRegEx);
    }

    public HttpInterceptorSupport.HttpAttacher forHttpMethod(HttpMethod method) {
        return interceptorSupport.forHttpMethod(method);
    }

    public HttpInterceptorSupport getInterceptorSupport() {
        return interceptorSupport;
    }

    public RequestHandler getRouter() {
        return router;
    }

    public HttpRequestHandler build() {
        interceptorSupport.finish();
        return new HttpRequestHandler(router, interceptorSupport);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy