mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
♻️ 重构代码。 gateway 降级获取原请求 ,docker-compose优化,日志优化
This commit is contained in:
1 parent
e6723861e8
commit
02846103cd
5 files changed
+12
-40
No files matched your search
+8
-1
@@ -27,6 +27,10 @@ import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/7/5
|
||||
@@ -37,7 +41,10 @@ import reactor.core.publisher.Mono;
|
||||
public class HystrixFallbackHandler implements HandlerFunction<ServerResponse> {
|
||||
@Override
|
||||
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
|
||||
log.error("网关执行请求:{}失败,hystrix服务降级处理", serverRequest.uri());
|
||||
Optional<Object> originalUris = serverRequest.attribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
|
||||
|
||||
originalUris.ifPresent(originalUri -> log.error("网关执行请求:{}失败,hystrix服务降级处理", originalUri));
|
||||
|
||||
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR.value())
|
||||
.contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("服务异常"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user