Java Code Examples for com.netflix.zuul.context.RequestContext#getResponseStatusCode()
The following examples show how to use
com.netflix.zuul.context.RequestContext#getResponseStatusCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageRedirectionFilter.java From api-layer with Eclipse Public License 2.0 | 5 votes |
/** * @return true if status code is 3XX */ @Override public boolean shouldFilter() { RequestContext context = RequestContext.getCurrentContext(); int status = context.getResponseStatusCode(); return HttpStatus.valueOf(status).is3xxRedirection(); }
Example 2
Source File: ProxyRedirectFilter.java From spring-cloud-netflix-zuul-websocket with Apache License 2.0 | 5 votes |
@Override public boolean shouldFilter() { RequestContext ctx = RequestContext.getCurrentContext(); boolean isRedirect = ctx.getResponseStatusCode() == 301 || ctx.getResponseStatusCode() == 302; if (!isRedirect) return false; boolean hasCorrectLocation = false; List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders(); for (Pair<String, String> zuulResponseHeader : zuulResponseHeaders) { if ("Location".equalsIgnoreCase(zuulResponseHeader.first())) { HttpServletRequest request = ctx.getRequest(); String path = urlPathHelper.getPathWithinApplication(request); Route route = routeLocator.getMatchingRoute(path); UriComponents redirectTo = ServletUriComponentsBuilder .fromHttpUrl(zuulResponseHeader.second()).build(); UriComponents routeLocation = ServletUriComponentsBuilder .fromHttpUrl(route.getLocation()).build(); if (redirectTo.getHost().equalsIgnoreCase(routeLocation.getHost()) && redirectTo.getPort() == routeLocation.getPort()) { String toLocation = ServletUriComponentsBuilder .fromHttpUrl(zuulResponseHeader.second()) .host(request.getServerName()) .port(request.getServerPort()) .replacePath( buildRoutePath(route, zuulResponseHeader.second())) .build().toUriString(); ctx.put(REDIRECT_TO_URL, toLocation); hasCorrectLocation = true; break; } } } return hasCorrectLocation; }
Example 3
Source File: LocationHeaderRewritingFilter.java From pulsar-manager with Apache License 2.0 | 4 votes |
@Override public boolean shouldFilter() { RequestContext ctx = RequestContext.getCurrentContext(); int statusCode = ctx.getResponseStatusCode(); return HttpStatus.valueOf(statusCode).is3xxRedirection(); }
Example 4
Source File: CacheUpdateFilter.java From ServiceComb-Company-WorkShop with Apache License 2.0 | 4 votes |
private boolean isSuccessfulFibonacciResponse(RequestContext context, String path) { return path.contains(pathInRequest()) && context.getResponseStatusCode() == SC_OK && context.sendZuulResponse() && (context.getResponseBody() != null || context.getResponseDataStream() != null); }
Example 5
Source File: CustomLocationRewriteFilter.java From microservices-springboot with MIT License | 4 votes |
@Override public boolean shouldFilter() { RequestContext ctx = RequestContext.getCurrentContext(); int statusCode = ctx.getResponseStatusCode(); return HttpStatus.valueOf(statusCode).is3xxRedirection() || HttpStatus.valueOf(statusCode) == HttpStatus.CREATED; }