void setRequestPath()

in aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/servlet/AwsProxyRequestDispatcher.java [125:146]


    void setRequestPath(ServletRequest req, final String destinationPath) {
        if (req instanceof AwsProxyHttpServletRequest) {
            ((AwsProxyHttpServletRequest) req).getAwsProxyRequest().setPath(dispatchTo);
            return;
        }
        if (req instanceof AwsHttpApiV2ProxyHttpServletRequest) {
            ((AwsHttpApiV2ProxyHttpServletRequest) req).getRequest().setRawPath(destinationPath);
            return;
        }

        log.debug("Request is not an proxy request generated by this library, attempting to extract the proxy event type from the request attributes");
        if (req.getAttribute(API_GATEWAY_EVENT_PROPERTY) != null && req.getAttribute(API_GATEWAY_EVENT_PROPERTY) instanceof AwsProxyRequest) {
            ((AwsProxyRequest)req.getAttribute(API_GATEWAY_EVENT_PROPERTY)).setPath(dispatchTo);
            return;
        }
        if (req.getAttribute(HTTP_API_EVENT_PROPERTY) != null && req.getAttribute(HTTP_API_EVENT_PROPERTY) instanceof HttpApiV2ProxyRequest) {
            ((HttpApiV2ProxyRequest)req.getAttribute(HTTP_API_EVENT_PROPERTY)).setRawPath(destinationPath);
            return;
        }

        throw new IllegalStateException("Could not set new target path for the given ServletRequest object");
    }