-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(hz): optimize the naming style for middleware #660
feat(hz): optimize the naming style for middleware #660
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## develop #660 +/- ##
========================================
Coverage 75.64% 75.64%
========================================
Files 97 97
Lines 9462 9462
========================================
Hits 7158 7158
Misses 1855 1855
Partials 449 449 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
e858bdf
to
1c87f8d
Compare
1c87f8d
to
4db85f6
Compare
_a := root.Group("/a", _aMw()...) |
这里解了命名冲突,会生成如下:
|
8c6acbf
to
e2a5647
Compare
72fff5f
to
917aca1
Compare
917aca1
to
389ada3
Compare
389ada3
to
f294e02
Compare
f294e02
to
174d08e
Compare
f2d9047
to
5f6dc38
Compare
…FFF/hertz into fix/handler_middleware_name
5f6dc38
to
2c1f151
Compare
What type of PR is this?
feat
Check the PR title.
(Optional) Translate the PR title into Chinese.
优化中间件的命名方式
(Optional) More detail description for this PR(en: English/zh: Chinese).
en: optimize the naming style for middleware
zh(optional): 优化中间件的命名方式
修改内容:
形如 "a/b" & "a/b/c" 这种路由的定义,生成的代码如下:
可以看到
_a.GET("/b", append(_bMw(), hertz.Method1)...)
和_b := _a.Group("/b", _bMw()...)
共用了同一个 middleware 函数。产生问题的原因是没有严格区分 "group middleware" 和 "handler middleware" 的命名方式,导致生产的代码共用了同一个中间件函数。预期生成的代码为:
是否有break:
如果有类似的路由注册,会多生成一个中间件,需要用户本身注意下是否需要增加修改中间件的内容
增加中间件命名风格:
增加以 "path" 作为分隔的中间件命名分隔,例如"a_b_mws()";从而不需要对中间件的命名进行 "Unique" 操作,进而对齐内部的命名方式
修复了一个命名转换的bug,会错误地将 "A"->"_"
Which issue(s) this PR fixes: