diff --git a/fizz-core/src/main/java/we/controller/CacheCheckController.java b/fizz-core/src/main/java/we/controller/CacheCheckController.java index 4f0aa71..7d62fa6 100644 --- a/fizz-core/src/main/java/we/controller/CacheCheckController.java +++ b/fizz-core/src/main/java/we/controller/CacheCheckController.java @@ -18,6 +18,7 @@ package we.controller; import org.openjdk.jol.info.GraphLayout; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -74,7 +75,7 @@ public class CacheCheckController { @Resource private CircuitBreakManager circuitBreakManager; - @Resource + @Autowired(required = false) private FlowStat flowStat; @GetMapping("/gatewayGroups") diff --git a/fizz-core/src/main/java/we/filter/FizzWebFilter.java b/fizz-core/src/main/java/we/filter/FizzWebFilter.java index c348584..2f3b21a 100644 --- a/fizz-core/src/main/java/we/filter/FizzWebFilter.java +++ b/fizz-core/src/main/java/we/filter/FizzWebFilter.java @@ -31,7 +31,7 @@ public abstract class FizzWebFilter implements WebFilter { @Override public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - if (WebUtils.isAdminReq(exchange) || WebUtils.isFizzReq(exchange)) { + if (WebUtils.isAdminReq(exchange) || WebUtils.isFizzReq(exchange) || WebUtils.isFavReq(exchange)) { return chain.filter(exchange); } else { return doFilter(exchange, chain); diff --git a/fizz-core/src/main/java/we/filter/FlowControlFilter.java b/fizz-core/src/main/java/we/filter/FlowControlFilter.java index fc741d0..2295943 100644 --- a/fizz-core/src/main/java/we/filter/FlowControlFilter.java +++ b/fizz-core/src/main/java/we/filter/FlowControlFilter.java @@ -77,6 +77,11 @@ public class FlowControlFilter extends FizzWebFilter { private static final String qps = "qps"; + private static final String favPath = "/favicon.ico"; + + + + @Resource private FlowControlFilterProperties flowControlFilterProperties; @@ -110,28 +115,37 @@ public class FlowControlFilter extends FizzWebFilter { ServerHttpRequest request = exchange.getRequest(); String path = request.getPath().value(); - int secFS = path.indexOf(Consts.S.FORWARD_SLASH, 1); - if (secFS == -1) { - return WebUtils.responseError(exchange, HttpStatus.INTERNAL_SERVER_ERROR.value(), "request path should like /optional-prefix/service-name/real-biz-path"); + boolean adminReq = false, proxyTestReq = false, fizzApiReq = false, favReq = false; + if (path.equals(favPath)) { + exchange.getAttributes().put(WebUtils.FAV_REQUEST, Consts.S.EMPTY); + favReq = true; } - String service = path.substring(1, secFS); - boolean adminReq = false, proxyTestReq = false, fizzApiReq = false; - if (service.equals(admin) || service.equals(actuator)) { - adminReq = true; - exchange.getAttributes().put(WebUtils.ADMIN_REQUEST, Consts.S.EMPTY); - } else if (service.equals(SystemConfig.DEFAULT_GATEWAY_TEST)) { - proxyTestReq = true; - } else { - service = WebUtils.getClientService(exchange); - if (service.startsWith(_fizz)) { - fizzApiReq = true; - exchange.getAttributes().put(WebUtils.FIZZ_REQUEST, Consts.S.EMPTY); + + String service = null; + if (!favReq) { + int secFS = path.indexOf(Consts.S.FORWARD_SLASH, 1); + if (secFS == -1) { + return WebUtils.responseError(exchange, HttpStatus.INTERNAL_SERVER_ERROR.value(), "request path should like /optional-prefix/service-name/real-biz-path"); } + service = path.substring(1, secFS); + + if (service.equals(admin) || service.equals(actuator)) { + adminReq = true; + exchange.getAttributes().put(WebUtils.ADMIN_REQUEST, Consts.S.EMPTY); + } else if (service.equals(SystemConfig.DEFAULT_GATEWAY_TEST)) { + proxyTestReq = true; + } else { + service = WebUtils.getClientService(exchange); + if (service.startsWith(_fizz)) { + fizzApiReq = true; + exchange.getAttributes().put(WebUtils.FIZZ_REQUEST, Consts.S.EMPTY); + } + } + + setTraceId(exchange); } - setTraceId(exchange); - - if (flowControlFilterProperties.isFlowControl() && !adminReq && !proxyTestReq && !fizzApiReq) { + if (!favReq && flowControlFilterProperties.isFlowControl() && !adminReq && !proxyTestReq && !fizzApiReq) { String traceId = WebUtils.getTraceId(exchange); // LogService.setBizId(traceId); org.apache.logging.log4j.ThreadContext.put(Consts.TRACE_ID, traceId); diff --git a/fizz-core/src/main/java/we/util/WebUtils.java b/fizz-core/src/main/java/we/util/WebUtils.java index 27deb31..608c978 100644 --- a/fizz-core/src/main/java/we/util/WebUtils.java +++ b/fizz-core/src/main/java/we/util/WebUtils.java @@ -109,6 +109,8 @@ public abstract class WebUtils { public static final String FIZZ_REQUEST = "fr@"; + public static final String FAV_REQUEST = "fa@"; + public static final String BODY_ENCRYPT = "b-ecyt"; public static final String ORIGINAL_ERROR = "origerr@"; @@ -117,6 +119,10 @@ public abstract class WebUtils { private WebUtils() { } + public static boolean isFavReq(ServerWebExchange exchange) { + return exchange.getAttribute(FAV_REQUEST) != null; + } + public static boolean isAdminReq(ServerWebExchange exchange) { return exchange.getAttribute(ADMIN_REQUEST) != null; }