12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.txz.project.configurer;
- // import org.springframework.cloud.netflix.zuul.filters.route.FallbackProvider;
- // import org.springframework.http.HttpHeaders;
- // import org.springframework.http.HttpStatus;
- // import org.springframework.http.MediaType;
- // import org.springframework.http.client.ClientHttpResponse;
- // import org.springframework.stereotype.Component;
- //
- // import java.io.ByteArrayInputStream;
- // import java.io.IOException;
- // import java.io.InputStream;
- //
- // /**
- // * @author: linjie
- // * @description:错误拦截回显,熔断
- // * @create: 2018/10/11 20:01
- // */
- // @Component
- // public class ApiFallbackProvider implements FallbackProvider{
- //
- // @Override
- // public String getRoute() {
- // //设置熔断的服务名
- // //如果是所有服务则设置为*
- // return "*";
- // }
- //
- // @Override
- // public ClientHttpResponse fallbackResponse(String route, Throwable cause) {
- // return new ClientHttpResponse() {
- // @Override
- // public HttpStatus getStatusCode() throws IOException {
- // return HttpStatus.OK;
- // }
- //
- // @Override
- // public int getRawStatusCode() throws IOException {
- // return 200;
- // }
- //
- // @Override
- // public String getStatusText() throws IOException {
- // return "{code:0,message:service error =_=}";
- // }
- //
- // @Override
- // public void close() {
- //
- // }
- //
- // @Override
- // public InputStream getBody() throws IOException {
- // return new ByteArrayInputStream("{\"code\":\"599\",\"message\":\"zuul Access Filter - The service is unavailable.\"}".getBytes());
- // }
- //
- // @Override
- // public HttpHeaders getHeaders() {
- // HttpHeaders headers = new HttpHeaders();
- // headers.setContentType(MediaType.APPLICATION_JSON);
- // return headers;
- // }
- // };
- // }
- //
- //
- // }
|