Java Code Examples for org.springframework.web.reactive.function.server.ServerRequest#attribute()

The following examples show how to use org.springframework.web.reactive.function.server.ServerRequest#attribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HystrixFallbackHandler.java    From smaker with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
	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("服务异常"));
}
 
Example 2
Source File: HystrixFallbackHandler.java    From spring-microservice-exam with MIT License 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
    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("服务异常"));
}
 
Example 3
Source File: HystrixFallbackHandler.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
	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())
		.header("Content-Type","text/plain; charset=utf-8").body(BodyInserters.fromObject("服务异常"));
}
 
Example 4
Source File: HystrixFallbackHandler.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
	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.fromValue("服务异常"));
}
 
Example 5
Source File: HystrixFallbackHandler.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
	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.fromValue("服务异常"));
}
 
Example 6
Source File: GatewayHystrix.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Override
public Mono<ServerResponse> handle(ServerRequest serverRequest) {
    Optional<Object> originalUris = serverRequest.attribute(GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
    originalUris.ifPresent(originalUri -> log.error("Request Url:{} , Service Hystrix", originalUri));
    return ServerResponse
            .status(HttpStatus.INTERNAL_SERVER_ERROR.value())
            .contentType(MediaType.TEXT_PLAIN)
            .body(BodyInserters.fromValue("No available server for this request"));
}