fix issue #4176: refactor Router with option pattern
This commit is contained in:
@@ -74,7 +74,7 @@ func oldMiddlewareToNew(mws []MiddleWare) []web.MiddleWare {
|
||||
// beego.Router("/api/update",&RestController{},"put:UpdateFood")
|
||||
// beego.Router("/api/delete",&RestController{},"delete:DeleteFood")
|
||||
func Router(rootpath string, c ControllerInterface, mappingMethods ...string) *App {
|
||||
return (*App)(web.Router(rootpath, c, mappingMethods...))
|
||||
return (*App)(web.Router(rootpath, c, web.WithMethods(c, mappingMethods...)))
|
||||
}
|
||||
|
||||
// UnregisterFixedRoute unregisters the route with the specified fixedRoute. It is particularly useful
|
||||
|
||||
@@ -272,7 +272,7 @@ func NSInclude(cList ...ControllerInterface) LinkNamespace {
|
||||
// NSRouter call Namespace Router
|
||||
func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace {
|
||||
return func(namespace *Namespace) {
|
||||
web.Router(rootpath, c, mappingMethods...)
|
||||
web.Router(rootpath, c, web.WithMethods(c, mappingMethods...))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func NewControllerRegister() *ControllerRegister {
|
||||
// Add("/api",&RestController{},"get,post:ApiFunc"
|
||||
// Add("/simple",&SimpleController{},"get:GetFunc;post:PostFunc")
|
||||
func (p *ControllerRegister) Add(pattern string, c ControllerInterface, mappingMethods ...string) {
|
||||
(*web.ControllerRegister)(p).Add(pattern, c, mappingMethods...)
|
||||
(*web.ControllerRegister)(p).Add(pattern, c, web.WithMethods(c, mappingMethods...))
|
||||
}
|
||||
|
||||
// Include only when the Runmode is dev will generate router file in the router/auto.go from the controller
|
||||
|
||||
Reference in New Issue
Block a user