如何在rpc server中使用自定义middleWare和exceptionHandler #3708
uuuuuuuu-s
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
rpc interface 尽管是内部调用,依然存在参数验证 权限验证的需求,用validation middleware解藕可以很方便的解决掉这个问题,文档中关于middleWare和exceptionHandler的使用教程,但在rpc server中需要做一些调整后才能使用。使用方法如下:
1.配置middleware和exceptionHandler参考官方文档的介绍即可,
https://hyperf.wiki/2.1/#/zh-cn/middleware/middleware
https://hyperf.wiki/2.1/#/zh-cn/exception-handler
注意:middleware的配置可以配置成下边这种格式,这样就可以对每个server做单独处理。
2.如果需要在middleware中截断请求,直接返回response,可参考以下代码:
Beta Was this translation helpful? Give feedback.
All reactions