chore: initialize branch

This commit is contained in:
hongqiaowei
2020-11-24 18:18:46 +08:00
parent 24688b2bb0
commit 8aba64bb39
5 changed files with 48 additions and 43 deletions

20
pom.xml
View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.10.RELEASE</version>
<version>2.2.11.RELEASE</version>
<relativePath/>
</parent>
<groupId>we</groupId>
@@ -34,10 +34,12 @@
<properties>
<java.version>1.8</java.version>
<log4j2.version>2.13.3</log4j2.version>
<netty.version>4.1.53.Final</netty.version>
<httpclient.version>4.5.13</httpclient.version>
<spring-framework.version>5.2.11.RELEASE</spring-framework.version>
<reactor-bom.version>Dysprosium-SR14</reactor-bom.version>
<lettuce.version>5.3.5.RELEASE</lettuce.version>
<nacos.version>0.2.7</nacos.version>
<netty.version>4.1.54.Final</netty.version>
<log4j2.version>2.13.3</log4j2.version>
</properties>
<dependencies>
@@ -67,7 +69,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.74</version>
<version>1.2.75</version>
</dependency>
<dependency>
@@ -146,13 +148,19 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.2.5.RELEASE</version>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>${nacos.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>

View File

@@ -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<Void> vm = WebUtils.responseError(exchange, filterExceptionHandler, HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), t);
return vm;
Mono<Void> vm = WebUtils.responseError(exchange, filterExceptionHandler, HttpStatus.INTERNAL_SERVER_ERROR.value(), t.getMessage(), t);
return vm;
}
}

View File

@@ -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;

View File

@@ -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));
}

View File

@@ -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<String> 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<String> 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);
}