package com.atlassian.stash.internal.scm.http;

import com.atlassian.bitbucket.scm.http.HttpScmRequestHandler;

import javax.annotation.Nonnull;
import javax.servlet.http.HttpServletRequest;
import java.util.Optional;

/**
 * Provides the enabled {@link HttpScmRequestHandler} that supports a given {@link HttpServletRequest}.
 */
public interface HttpScmRequestHandlerProvider {

    /**
     * @param req an {@link HttpServletRequest} from an scm client
     * @return an {@link HttpScmRequestHandler} if there is an enabled {@link HttpScmRequestHandlerProvider} that can
     * service the supplied request, or {@link Optional#empty()} otherwise.
     */
    @Nonnull
    Optional<HttpScmRequestHandler> getHandler(HttpServletRequest req);
}
