class LocationFilter extends ZuulFilter implements RoutedServicesUser {

    @Override
    public Object run() {
        RequestContext context = RequestContext.getCurrentContext();

        final String serviceId = (String) context.get(SERVICE_ID_KEY);
        final String proxy = UrlUtils.removeFirstAndLastSlash((String) context.get(PROXY_KEY));
        final String requestPath = UrlUtils.addFirstSlash((String) context.get(REQUEST_URI_KEY));

        if (isRequestThatCanBeProcessed(serviceId, proxy, requestPath)) {
            RoutedServices routedServices = routedServicesMap.get(serviceId);

            if (routedServices != null) {
                @SuppressWarnings("squid:S2259")
                int i = proxy.lastIndexOf('/');

                if (i > 0) {
                    String originalPath = normalizeOriginalPath(getService(routedServices, proxy).getServiceUrl());
                    context.set(REQUEST_URI_KEY, originalPath + requestPath);
                    log.debug("Routing: The request was routed to {}", originalPath + requestPath);
                }
            } else {
                log.trace("Routing: No routing metadata for service {} found.", serviceId);
            }
        } else {
            log.trace("Routing: Incorrect serviceId {}, proxy {} or requestPath {}.", serviceId, proxy, requestPath);
        }

        return null;
    }

}