router.go
1.0 KB
package routers
import (
"oppmg/controllers"
"oppmg/middleware"
"github.com/astaxie/beego"
)
func init() {
nsV1 := beego.NewNamespace("v1",
beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
beego.NSNamespace("/company",
beego.NSRouter("/department", &controllers.CompanyController{}, "post:DepartmentAdd"),
beego.NSRouter("/department", &controllers.CompanyController{}, "put:DepartmentUpdate"),
beego.NSRouter("/department", &controllers.CompanyController{}, "delete:DepartmentDelete"),
),
beego.NSNamespace("/rbac",
beego.NSRouter("/role", &controllers.CompanyController{}, "post:RoleAdd"),
beego.NSRouter("/role", &controllers.CompanyController{}, "put:RoleUpdate"),
beego.NSRouter("/role", &controllers.CompanyController{}, "delete:RoleDelete"),
),
)
nsAuth := beego.NewNamespace("/auth",
beego.NSBefore(middleware.LogRequestData, middleware.AuthToken),
beego.NSRouter("/accessToken", &controllers.AuthController{}, "post:AccessToken"),
)
beego.AddNamespace(nsV1)
beego.AddNamespace(nsAuth)
}