zuul是什么?
不知道的请Google或者百度;
Zuul过滤器生命周期:
image.pngZuulServlet.service()方法代码片段:
try {
preRoute();
} catch (ZuulException e) {
error(e);
postRoute();
return;
}
try {
route();
} catch (ZuulException e) {
error(e);
postRoute();
return;
}
try {
postRoute();
} catch (ZuulException e) {
error(e);
return;
}
} catch (Throwable e) {
error(new ZuulException(e, 500, "UNHANDLED_EXCEPTION_" + e.getClass().getName()));
} finally {
RequestContext.getCurrentContext().unset();
}
注意:preRoute()用于前置过滤器;postRoute()用于后置过滤器;route()用于路由转发过滤器;error(e)用于发生错误的过滤器;结合代码和图,相信聪明的你已经看懂了zuulServlet的生命周期;如果还看不懂,请参考https://github.com/Netflix/zuul/wiki/How-it-Works
Zuul默认过滤器:
image.pngZuul默认前置过滤器:
image.png- RateLimitPreFilter
- AuthenticationHeaderFilter
- Servlet30WrapperFilter
- ServletDetectionFilter
- PreDecorationFilter
- DebugFilter
- FormBodyWrapperFilter
- OAuth2TokenRelayFilter
- TracePreZuulFilter
Zuul默认路由过滤器:
image.png- SimpleHostRoutingFilter
- RibbonRoutingFilter
- SendForwardFilter
Zuul默认后置过滤器:
image.png- TracePostZuulFilter
- RateLimitPostFilter
- SendResponseFilter
Zuul默认错误路由器:
- SendErrorFilter
网友评论