由于版本迭代,有的时候需要做老接口的兼容适配,有很多种方式,比如在nginx配置路由规则,在网关配置路由规则,本篇通过使用反射的方式在网关层全局过滤器中重写request请求的方式实现url适配。
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.spr