网关拦截器
使用方法如下:
- 在sop-gateway工程下新增一个类,实现接口,实现接口中的方法。别忘了加
@Component
RouteInterceptor接口方法说明:
public void preRoute(RouteInterceptorContext context)
路由转发完成后,即拿到微服务返回结果后执行这个方法
public int getOrder()
指定拦截执行顺序,数字小的优先执行,建议从0开始。
default boolean match(RouteInterceptorContext context)
RouteInterceptorContext参数存放了各类参数信息。
参考类:
com.gitee.sop.gatewaycommon.interceptor.RouteInterceptorContext
拦截器上下文com.gitee.sop.gatewaycommon.interceptor.MonitorRouteInterceptor
默认实现的拦截器,用于收集监控数据