没有路由匹配时在Spring Cloud Gateway中发送自定义错误响应

时间:2020-03-08 20:21:38

标签: spring spring-cloud-gateway

在Spring Cloud Gateway中,我想发送自定义错误,以防特定谓词匹配失败。例如: 我有一个路径和标头谓词。像这样-

- id: test
  uri: http://localhost:8000/
  predicates:
   - Path=/consignment
   - Header=h,h1

因此,如果路径mathces和标头不存在,则请求失败,并且未找到错误,默认情况下类似

{
    "timestamp": "2020-03-08T20:05:42.440+0000",
    "path": "/test",
    "status": 404,
    "error": "Not Found",
    "message": null,
    "requestId": "6dd2e799"
}

但是我想发送一个自定义响应,提到标题不存在。 有办法吗?

0 个答案:

没有答案
相关问题