文章目录
解决问题:我们开发中遇到的问题,h5不需要登录以游客模式查看信息,但是接口过多,而且逻辑也比较复杂,所以我们在后端指定接口伪装一个内部账号登录。
gateway配置
@Component
@Slf4j
@AllArgsConstructor
public class HttpRequestFilter implements GlobalFilter, Ordered {
@Resource
private RestTokenClient restTokenClient;
@Resource
private GatewayUrlProperties gatewayUrlProperties;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
String path = request.getURI().getPath();
if (path.contains("/oauth/current")) {
return chain.filter(exchange);
}
String appVersion = request.getHeaders().getFirst("appVersion");
String plat = request.getHeaders().getFirst("plat");
if (StringUtils.isNotEmpty(plat)) {
switch (plat) {
case "1":
plat = "IOS";
break;
case "2":
plat = "ANDROID"