add SessionOn option for web.Router

This commit is contained in:
AllenX2018
2020-11-24 10:15:28 +08:00
parent 463ec4b085
commit 963de3e68b
9 changed files with 61 additions and 42 deletions

View File

@@ -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, web.WithMethods(c, mappingMethods...)))
return (*App)(web.Router(rootpath, c, web.SetRouterMethods(c, mappingMethods...)))
}
// UnregisterFixedRoute unregisters the route with the specified fixedRoute. It is particularly useful

View File

@@ -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, web.WithMethods(c, mappingMethods...))
web.Router(rootpath, c, web.SetRouterMethods(c, mappingMethods...))
}
}

View File

@@ -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, web.WithMethods(c, mappingMethods...))
(*web.ControllerRegister)(p).Add(pattern, c, web.SetRouterMethods(c, mappingMethods...))
}
// Include only when the Runmode is dev will generate router file in the router/auto.go from the controller