use of org.springframework.http.client.ClientHttpResponse in project paascloud-master by paascloud.
the class UacFallbackProvider method response.
private ClientHttpResponse response(final HttpStatus status) {
return new ClientHttpResponse() {
@Override
public HttpStatus getStatusCode() {
return status;
}
@Override
public int getRawStatusCode() {
return status.value();
}
@Override
public String getStatusText() {
return status.getReasonPhrase();
}
@Override
public void close() {
log.info("close");
}
@Override
public InputStream getBody() {
String message = "{\n" + "\"code\": 200,\n" + "\"message\": \"微服务故障, 请稍后再试\"\n" + "}";
return new ByteArrayInputStream(message.getBytes());
}
@Override
public HttpHeaders getHeaders() {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return headers;
}
};
}
Aggregations