覆盖Zuul过滤器SendErrorFilter [英] Overriding Zuul Filter SendErrorFilter

查看:154
本文介绍了覆盖Zuul过滤器SendErrorFilter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter类处理错误响应.

The class org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter handles error responses.

我想在转发等操作时覆盖此过滤器以执行自定义响应,而不是ZuulException.

I would like to override this filter to do a custom response instead of the ZuulException while forwarding etc.

如何用自己的版本替换它? 只是写和注册?是这样做还是有其他需要?

How can I replace this with my own version? Just write and register? Would that do it or is there something else needed?

推荐答案

您需要做的就是创建一个ZuulFilter并将其公开为@Bean.它必须按顺序设置在0之前的SendErrorFilter之前.您可能需要从RequestContext中删除"error.status_code",以使SendErrorFilter不运行.

all you need to do is create a ZuulFilter and expose it as an @Bean. It needs to be in order before SendErrorFilter which is set to 0. You might need to remove "error.status_code" from the RequestContext so SendErrorFilter doesn't run.

这篇关于覆盖Zuul过滤器SendErrorFilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆