|
@@ -1,6 +1,10 @@
|
|
package com.diagbot.filter;
|
|
package com.diagbot.filter;
|
|
|
|
|
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
|
+import com.diagbot.entity.User;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
|
@@ -23,6 +27,8 @@ import java.util.LinkedHashSet;
|
|
public class GlobalGatewayFilter implements GlobalFilter {
|
|
public class GlobalGatewayFilter implements GlobalFilter {
|
|
private static final String GATE_WAY_PREFIX = "/api";
|
|
private static final String GATE_WAY_PREFIX = "/api";
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private UserServiceClient userServiceClient;
|
|
@Override
|
|
@Override
|
|
public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain gatewayFilterChain) {
|
|
public Mono<Void> filter(ServerWebExchange serverWebExchange, GatewayFilterChain gatewayFilterChain) {
|
|
log.info("check token and url permission....");
|
|
log.info("check token and url permission....");
|
|
@@ -40,9 +46,11 @@ public class GlobalGatewayFilter implements GlobalFilter {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ RespDTO<User> userRespDTO = userServiceClient.login("admin","a123456");
|
|
log.info("APIURL:{}", requestUri);
|
|
log.info("APIURL:{}", requestUri);
|
|
log.info("SERVICENAME:{}", serviceName);
|
|
log.info("SERVICENAME:{}", serviceName);
|
|
//
|
|
//
|
|
|
|
+
|
|
ServerHttpRequest.Builder builder = serverWebExchange.getRequest().mutate();
|
|
ServerHttpRequest.Builder builder = serverWebExchange.getRequest().mutate();
|
|
builder.header("Authorization","Authorization Bearer token");
|
|
builder.header("Authorization","Authorization Bearer token");
|
|
gatewayFilterChain.filter(serverWebExchange.mutate().request(builder.build()).build());
|
|
gatewayFilterChain.filter(serverWebExchange.mutate().request(builder.build()).build());
|