使用Zull管理端点

返回目录:

https://blog.csdn.net/BW_Bear/article/details/88746646

源码位置:

微服务注册:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Zuul构建微服务网关/microservice-discovery-eureka

生产者:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Zuul构建微服务网关/microservice-provider-user

消费者:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Zuul构建微服务网关/microservice-consumer-movie-ribbon

网关:

https://github.com/zhaowei-zhang/CloudTest/tree/master/使用Zuul构建微服务网关/microservice-gateway-zuul

使用Zull管理端点

当@EnableZuulProxy与Spring Boot Actuator配合使用时,Zuul会暴露两个端点:/routes 和 filters 借助这些端点,可方便、直观的查看以及管理Zuul。

routes 端点

1.使用GET方法访问该端点,即可返回Zuul当前映射路由

2.使用POST方法访问该端点,就会强制刷新Zuul的当前映射路由

3.Spring Cloud Edgware对/routes端点进行进一步增强,可以使用/routes?format=details

由于spring-cloud-starter-netflix-zuul已经包含了spring-boot-starter-actuator,因此不需要再次增加依赖。

启动

1.启动eureka、生产者、消费者、Zuul微服务网关

1
使用Zull管理端点_第1张图片

测试

1. /routes

3
在这里插入图片描述

{
	"/microservice-consumer-movie/**": "microservice-consumer-movie",
	"/microservice-provider-user/**": "microservice-provider-user"
}

2. /routes?format=details

2
在这里插入图片描述

{
	"/microservice-consumer-movie/**": {
		"id": "microservice-consumer-movie",
		"fullPath": "/microservice-consumer-movie/**",
		"location": "microservice-consumer-movie",
		"path": "/**",
		"prefix": "/microservice-consumer-movie",
		"retryable": false,
		"customSensitiveHeaders": false,
		"prefixStripped": true
	},
	"/microservice-provider-user/**": {
		"id": "microservice-provider-user",
		"fullPath": "/microservice-provider-user/**",
		"location": "microservice-provider-user",
		"path": "/**",
		"prefix": "/microservice-provider-user",
		"retryable": false,
		"customSensitiveHeaders": false,
		"prefixStripped": true
	}
}

filters 端点

1.Zuul提供/filters端点。访问该端点即可返回Zuul中当前所有过滤器的情况,并按照类型划分

测试

/filters

4
使用Zull管理端点_第2张图片

{
  "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
    }
  ]
}

返回目录:

https://blog.csdn.net/BW_Bear/article/details/88746646

你可能感兴趣的:(SpringCloud)