0

如果尤里卡服务ID使用zuul路线,服务还有些则httpStatus像503spring云zuul:如何返回服务httpstatus(或处理zuul状态返回)?

curl 10.1.0.21:5701/usr/users/xxx/a -H "Api-Version: v10" -i 

返回:

HTTP/1.1 503 Service Unavailable 
Set-Cookie: Session-Token=9e66fb56-21e2-457a-a00f-f788c5ce820b; path=/; domain=.0.21:5701; HttpOnly; Max-Age=2592000; Expires=Sat, 29-Oct-2016 09:23:41 GMT 
Date: Thu, 29 Sep 2016 09:23:41 GMT 
Session-Token-Expires: 2592000 
Connection: keep-alive 
ETag: 
Session-Token: 9e66fb56-21e2-457a-a00f-f788c5ce820b 
Transfer-Encoding: chunked 
Content-Type: application/json;charset=UTF-8 
X-Application-Context: user-api-provider:5701 
Content-Language: en- 
Access-Control-Max-Age: 1728000 

[{"key":"serviceUnavailable","message":"无效的接口"}] 

但zuul reuturns OK/200,为什么呢?我如何改变Zuul如何处理状态?

curl 10.1.0.19:8090/usr/users/xxx/a -H "Api-Version: v10" -i 

返回:

HTTP/1.1 200 OK 
Connection: keep-alive 
Content-Length: 0 
X-Application-Context: zuul-server:8090 
Date: Thu, 29 Sep 2016 09:24:10 GMT 

回答

0

对我的作品与最新的弹簧云的Netflix(1.2.0):

@SpringBootApplication 
@EnableZuulProxy 
public class SimpleApplication { 

    public static void main(String[] args) { 
     SpringApplication.run(SimpleApplication.class, args); 
    } 
} 

application.properties

zuul.routes.test.url=http://httpstat.us/503 
zuul.routes.test.path=/test/** 

和:

$ curl localhost:8080/test/ 
> GET /test/ HTTP/1.1 
> User-Agent: curl/7.35.0 
> Host: localhost:8080 
> Accept: */* 
> 
< HTTP/1.1 503 
< X-Application-Context: application 
< Cache-Control: private 
< X-AspNetMvc-Version: 5.1 
< X-AspNet-Version: 4.0.30319 
< X-Powered-By: ASP.NET 
< Access-Control-Allow-Origin: * 
< Date: Thu, 29 Sep 2016 10:24:16 GMT 
< Content-Type: text/plain;charset=utf-8 
< Transfer-Encoding: chunked 
< Connection: close 
< 
* Closing connection 0 
503 Service Unavailable$ 
+0

有在'弹簧云起动parent'没有版本匹配? – Dreampie

+0

我发现它'Camden.RELEASE',谢谢 – Dreampie