diff --git a/pom.xml b/pom.xml index 691a288..46d32bc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.2.10.RELEASE + 2.2.11.RELEASE we @@ -34,10 +34,12 @@ 1.8 - 2.13.3 - 4.1.53.Final - 4.5.13 + 5.2.11.RELEASE + Dysprosium-SR14 + 5.3.5.RELEASE 0.2.7 + 4.1.54.Final + 2.13.3 @@ -67,7 +69,7 @@ com.alibaba fastjson - 1.2.74 + 1.2.75 @@ -146,13 +148,19 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-client - 2.2.5.RELEASE + 2.2.6.RELEASE com.alibaba.boot nacos-config-spring-boot-starter ${nacos.version} + + + org.springframework.boot + spring-boot-starter-logging + + com.alibaba.boot diff --git a/src/main/java/we/filter/FilterExceptionHandlerConfig.java b/src/main/java/we/filter/FilterExceptionHandlerConfig.java index ac8eea1..a714090 100644 --- a/src/main/java/we/filter/FilterExceptionHandlerConfig.java +++ b/src/main/java/we/filter/FilterExceptionHandlerConfig.java @@ -55,8 +55,8 @@ public class FilterExceptionHandlerConfig { return resp.writeWith(Mono.just(resp.bufferFactory().wrap(ex.getData().toString().getBytes()))); } } - if (t instanceof RedirectException) { - RedirectException ex = (RedirectException) t; + if (t instanceof RedirectException) { + RedirectException ex = (RedirectException) t; if (ex.getRedirectUrl() != null) { ServerHttpResponse resp = exchange.getResponse(); resp.setStatusCode(HttpStatus.MOVED_PERMANENTLY); @@ -64,23 +64,22 @@ public class FilterExceptionHandlerConfig { return Mono.empty(); } } - if (t instanceof ExecuteScriptException) { - ExecuteScriptException ex = (ExecuteScriptException) t; - ServerHttpResponse resp = exchange.getResponse(); - resp.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - - RespEntity rs = null; - String reqId = exchange.getRequest().getId(); - if (ex.getStepContext() != null && ex.getStepContext().returnContext()) { - rs = new RespEntity(HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), reqId, ex.getStepContext()); - return resp.writeWith(Mono.just(resp.bufferFactory().wrap(JacksonUtils.writeValueAsString(rs).getBytes()))); - }else { - rs = new RespEntity(HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), reqId); - return resp.writeWith(Mono.just(resp.bufferFactory().wrap(rs.toString().getBytes()))); + if (t instanceof ExecuteScriptException) { + ExecuteScriptException ex = (ExecuteScriptException) t; + ServerHttpResponse resp = exchange.getResponse(); + resp.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); + RespEntity rs = null; + String reqId = exchange.getRequest().getId(); + if (ex.getStepContext() != null && ex.getStepContext().returnContext()) { + rs = new RespEntity(HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), reqId, ex.getStepContext()); + return resp.writeWith(Mono.just(resp.bufferFactory().wrap(JacksonUtils.writeValueAsString(rs).getBytes()))); + } else { + rs = new RespEntity(HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), reqId); + return resp.writeWith(Mono.just(resp.bufferFactory().wrap(rs.toString().getBytes()))); } } - Mono vm = WebUtils.responseError(exchange, filterExceptionHandler, HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), t); - return vm; + Mono vm = WebUtils.responseError(exchange, filterExceptionHandler, HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), t); + return vm; } } diff --git a/src/main/java/we/legacy/RespEntity.java b/src/main/java/we/legacy/RespEntity.java index a85d7af..a3155b4 100644 --- a/src/main/java/we/legacy/RespEntity.java +++ b/src/main/java/we/legacy/RespEntity.java @@ -32,7 +32,7 @@ public class RespEntity { private static final String f1 = ",\"message\":\""; private static final String f2 = "\"}"; - public int msgCode; + public int msgCode; public String message; diff --git a/src/main/java/we/proxy/FizzWebClient.java b/src/main/java/we/proxy/FizzWebClient.java index 90a550e..bcecd60 100644 --- a/src/main/java/we/proxy/FizzWebClient.java +++ b/src/main/java/we/proxy/FizzWebClient.java @@ -219,8 +219,6 @@ public class FizzWebClient { // TODO 请求完成后,做metric, 以反哺后续的请求转发 } - - private String extractServiceOrAddress(String uriOrSvc) { return uriOrSvc.substring(7, uriOrSvc.indexOf(Constants.Symbol.FORWARD_SLASH, 10)); } diff --git a/src/main/java/we/util/WebUtils.java b/src/main/java/we/util/WebUtils.java index 775d10d..fba2c3e 100644 --- a/src/main/java/we/util/WebUtils.java +++ b/src/main/java/we/util/WebUtils.java @@ -44,18 +44,6 @@ public abstract class WebUtils { private static final Logger log = LoggerFactory.getLogger(WebUtils.class); - public static final String APP_HEADER = "fizz-appid"; - - private static final String directResponse = "directResponse"; - - public static final String FILTER_CONTEXT = "filterContext"; - - public static final String APPEND_HEADERS = "appendHeaders"; - - public static final String PREV_FILTER_RESULT = "prevFilterResult"; - - public static final String request_path = "reqPath"; - private static final String SERVICE_ID = "serviceId"; private static final String xForwardedFor = "X-FORWARDED-FOR"; @@ -66,16 +54,28 @@ public abstract class WebUtils { private static final String binaryAddress = "0:0:0:0:0:0:0:1"; - public static boolean logResponseBody = false; - - public static Set logHeaderSet = Collections.EMPTY_SET; + private static final String directResponse = "directResponse"; private static final String response = " response "; private static final String originIp = "originIp"; - - public static final String PATH_PREFIX = "/proxy/"; + public static final String APP_HEADER = "fizz-appid"; + + public static final String FILTER_CONTEXT = "filterContext"; + + public static final String APPEND_HEADERS = "appendHeaders"; + + public static final String PREV_FILTER_RESULT = "prevFilterResult"; + + public static final String request_path = "reqPath"; + + public static boolean logResponseBody = false; + + public static Set logHeaderSet = Collections.EMPTY_SET; + + public static final String PATH_PREFIX = "/proxy/"; + public static String getHeaderValue(ServerWebExchange exchange, String header) { return exchange.getRequest().getHeaders().getFirst(header); }