I developed a PreFilter
for Zuul
which does some checks on a request containing a JWT
and if every checks goes OK, routes the request to the target Microservice.
What I'd like to do is to get the response HTTP
status code.
I'm trying to develop a PostFilter
in charge of getting the HTTP
status code, but I'm stuck on it.
public class PostFilter extends ZuulFilter {
@Override
public boolean shouldFilter() {
// TODO Auto-generated method stub
return true;
}
@Override
public String filterType() {
// TODO Auto-generated method stub
return "post";
}
@Override
public int filterOrder() {
// TODO Auto-generated method stub
return 2;
}
@Override
public Object run() throws ZuulException {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletResponse response = ctx.getResponse();
int statusCode = response.getStatus();
System.out.println(statusCode);
return null;
}
}
The System.out.println()
statement prints 0
.
How can I solve it? Thank you guys.
而是使用: context.getResponseStatusCode()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.