Spring Cloud Edgware新特性之五:filters端点

96
周立_itmuch
2017.10.30 11:08* 字数 301

Spring Cloud是当前炙手可热的微服务开发框架。它的功能强大,组件丰富,设计优雅。目前Spring Cloud还在不断发展之中。

Spring Cloud即将发布Spring Cloud Edgware 版本。该版本解决了不少Bug,新增了不少新特性,本系列博客将为大家详细阐述在Spring Cloud Edgware中新增的特性。

我们知道,过滤器是Zuul的核心。笔者曾经写过两篇文章介绍过滤器:

在Spring Cloud Edgware版本中,新增了/filters 端点。访问该端点即可返回Zuul中当前所有过滤器的详情,并按照类型分类。

如下是 /filters 端点的展示结果,从中,我们可以了解当前Zuul中, errorpostpreroute 四种类型的过滤器分别有哪些,每个过滤器的order (执行顺序)是多少,以及是否启用等信息。这对于Zuul问题的定位很有用。

{
    "error": [
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter",
            "order": 0,
            "disabled": false,
            "static": true
        }
    ],
    "post": [
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.post.SendResponseFilter",
            "order": 1000,
            "disabled": false,
            "static": true
        }
    ],
    "pre": [
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.pre.DebugFilter",
            "order": 1,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.pre.FormBodyWrapperFilter",
            "order": -1,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.pre.Servlet30WrapperFilter",
            "order": -2,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.pre.ServletDetectionFilter",
            "order": -3,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.pre.PreDecorationFilter",
            "order": 5,
            "disabled": false,
            "static": true
        }
    ],
    "route": [
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter",
            "order": 100,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter",
            "order": 10,
            "disabled": false,
            "static": true
        },
        {
            "class": "org.springframework.cloud.netflix.zuul.filters.route.SendForwardFilter",
            "order": 500,
            "disabled": false,
            "static": true
        }
    ]
}

本文首发

http://www.itmuch.com/spring-cloud/edgware-zuul-filters-endpoint/

干货分享

全是干货
Spring Cloud
Web note ad 1