beego / bee

Bee is a tool for helping develop with beego app framework.
Apache License 2.0
1.44k stars 921 forks source link

bee generate routers 支持/{*}这种形式生成路由也能正常访问 #836

Open gosszhang opened 2 years ago

gosszhang commented 2 years ago

路径中带有参数时,当前bee generate routers 只支持 /: 这种格式生成路由,如果换成 /{} ,能生成路由,但是访问是404。 示例: 路由注释一:

// @router      /project/:id [get]

生成路由是:

            Method: "GetOne",
            Router: `/project/:id`,
            AllowHTTPMethods: []string{"get"},
            MethodParams: param.Make(),

使用 /project/1 访问,正常

路由注释二:

// @router      /project/{id} [get]

生成路由是:

            Method: "GetOne",
            Router: `/project/{id}`,
            AllowHTTPMethods: []string{"get"},
            MethodParams: param.Make(),

使用 /project/1 访问,报错404

是否考虑支持/{} 生成的路由也能访问。swagger文档中路径参数格式就是/{}这样。