zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
28.31k stars 3.85k forks source link

zero #4203

Open HanWuJiJack opened 2 weeks ago

HanWuJiJack commented 2 weeks ago

在流控和熔断中间件内部 我看到的如果出现错误 会改状态码为503等,我感觉返回503不细致。如果我想拦截改写返回值应该怎么做?

Issues-translate-bot commented 2 weeks ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Within the flow control and fuse middleware, I saw that if an error occurs, the status code will be changed to 503, etc. I feel that returning 503 is not meticulous. What should I do if I want to intercept and rewrite the return value?

kevwan commented 2 weeks ago

You can disable the BreakerHandler and add your own.

HanWuJiJack commented 2 weeks ago

我知道可以自定义,那你们提供的中间件还有什么意义呢?我认为你们可以把中间件添加到开始位置的方法暴露出来,这样应该也可以捕获到具体状态码进行改写返回值!

Issues-translate-bot commented 2 weeks ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I know it can be customized, but what’s the point of the middleware you provide? I think you can expose the method of adding middleware to the beginning, so that you can capture the specific status code and rewrite the return value!