class SlashFilter extends ZuulFilter {

    @Override
    public Object run() {
        RequestContext context = RequestContext.getCurrentContext();
        String proxy = UrlUtils.removeFirstAndLastSlash((String) context.get(PROXY_KEY));
        if (proxy != null && !proxy.isEmpty()) {
            context.setSendZuulResponse(false);
            context.addZuulResponseHeader("Location", "/" + proxy + "/");
            context.setResponseStatusCode(HttpServletResponse.SC_MOVED_TEMPORARILY);
        }
        return null;
    }

}