router.go
1.7 KB
package routers
import (
"github.com/astaxie/beego"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"opp/controllers"
"opp/controllers/v1"
"opp/services/websocket"
)
var nsV1 *beego.Namespace
func init() {
nsV1 := beego.NewNamespace("v1",
beego.NSNamespace("ucenter", beego.NSInclude(&v1.UcenterController{})),
beego.NSNamespace("auth", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.AuthController{})),
beego.NSNamespace("upload", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.UploadController{})),
beego.NSNamespace("version", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.VersionController{})),
beego.NSNamespace("commend", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.CommendController{})),
beego.NSNamespace("user", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.UserController{})),
beego.NSNamespace("chance", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ChanceController{})),
beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})),
beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})),
)
beego.AddNamespace(nsV1)
nsH5 := beego.NewNamespace("h5", beego.NSBefore(controllers.LogRequestData), beego.NSBefore(controllers.AllowOption), beego.NSInclude(&controllers.H5Controller{}))
beego.AddNamespace(nsH5)
beego.SetStaticPath("/file/opp", beego.AppConfig.String("source_path"))
beego.SetStaticPath("/log", beego.AppConfig.String("aliyun_logs_access"))
beego.Handler("/metrics", promhttp.Handler())
beego.Handler("/upgrage", http.HandlerFunc(websocket.Upgrage))
}