cloudwego / hertz

Go HTTP framework with high-performance and strong-extensibility for building micro-services.
https://www.cloudwego.io
Apache License 2.0
5.04k stars 491 forks source link

Some problem about "hz update" #1116

Closed ChinaPhpZyp closed 3 months ago

ChinaPhpZyp commented 3 months ago

Describe the Question

A clear and concise description of what the question is.

Expected behavior

Steps to reproduce the behavior:

  1. At first, we have a service called "getCustomerMessageList" with route is "/seller/customer/message/list" . The route have the function for middle is "message0Mv()"
  2. Some time later, the other teammate write a service called "userAndCustomerList" with route is "/message/customer".
  3. The getCustomerMessageList's router will change to bind "message1Mv()", and "message0Mv()" will be bind by the userAndCustomerList.
  4. Then the route will be useless because the middleware is Auth Validate

I just want to ask some ways to deal this . Maybe the "thirft" file can support to wirte the relation of the route and the middleware

Screenshots

func _message0Mw() []app.HandlerFunc {
    return nil
}

func _message2Mw() []app.HandlerFunc {
    // your code...
    return []app.HandlerFunc{
        jwt.JWTAuth(config.GlobalServerConfig.JWTInfo.SigningKey),
    }
}

Hertz version:

hz version v0.8.1

li-jin-gou commented 3 months ago

cc @FGYFFFF

FGYFFFF commented 3 months ago

@ChinaPhpZyp 这个可能是由于解析 "路由树" 时没有严格排序带来的极端case 在最新版本,我们加入了一个新的选项 "-sort_router",他会对路由树进行严格的排序,确保你每次 update 后的路由都是确定的,避免随机性。 但是他可能会对当前的 router.go 的格式带来一些变化,但是不会影响路由注册的正确性

ChinaPhpZyp commented 3 months ago

@FGYFFFF 好的,感觉解答,更新到v0.9版本后看到了这个选项,我们后续持续观测一下