springboot springcloud zuul 过滤器
作者:互联网
1.继承类:ZuulFilter
2.使用场景:验证权限
1.继承类:ZuulFilter
package com.ligy.school.zuul.filter; import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.exception.ZuulException; import org.springframework.stereotype.Component; @Component public class AuthFilter extends ZuulFilter { public String filterType() { //pre 请求前面 post请求后面 error发生错误时 //route 在路由请求时被调用 return "pre"; } public int filterOrder() { //执行顺序 0 1 2 最先执行的是0,小的先执行 return 0; } public boolean shouldFilter() { //开关:true 打开 false:关闭 return true; } public Object run() throws ZuulException { //返回Object 就等于放行 System.out.println("过滤器,执行了"); return null; } }
2.使用场景:验证权限
标签:return,springboot,springcloud,com,import,zuul,ZuulFilter,public 来源: https://www.cnblogs.com/ligenyun/p/15808730.html