Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Main = gcmd.Command{ Name: "KysionShared", Usage: "KysionShared", Brief: "Start http server", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { var ( s = g.Server() oai = s.GetOpenApi() ) { oai.Info.Title = `API Reference` oai.Config.CommonResponse = api_v1.JsonRes{} oai.Config.CommonResponseDataField = `Data` } { uploadPath := g.Cfg().MustGet(ctx, "upload.path").String() if uploadPath == "" { g.Log().Fatal(ctx, "文件上传配置路径不能为空!") } if !gfile.Exists(uploadPath) { _ = gfile.Mkdir(uploadPath) } s.AddStaticPath("/upload", uploadPath) } { } { if gmode.IsDevelop() { s.BindHookHandler("/*", ghttp.HookBeforeServe, func(r *ghttp.Request) { r.Response.Header().Set("Cache-Control", "no-store") }) } } { consts.Global.UserDefaultType = g.Cfg().MustGet(ctx, "service.userDefaultType", 0).Int() } { serviceWorkerId := g.Cfg().MustGet(ctx, "service.idGeneratorWorkerId").Uint16() if serviceWorkerId < 1 || serviceWorkerId > 63 { g.Log().Fatal(ctx, "service.serviceWorkerId 取值范围只能是 1 ~ 63") return nil } // 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId: var options = idgen.NewIdGeneratorOptions(serviceWorkerId) options.WorkerIdBitLength = 10 idgen.SetIdGenerator(options) } { validator.RegisterServicePhone() } { service.Casbin().Enforcer() } { apiPrefix := g.Cfg().MustGet(ctx, "service.apiPrefix").String() s.Group(apiPrefix, func(group *ghttp.RouterGroup) { group.Middleware( service.Middleware().Casbin, service.Middleware().CTX, service.Middleware().ResponseHandler, ) group.Group("/", func(group *ghttp.RouterGroup) { group.Group("/auth", func(group *ghttp.RouterGroup) { group.Bind(sysController.Auth) }) group.Group("/common", func(group *ghttp.RouterGroup) { group.Bind( sysController.Captcha, sysController.SysSms, sysController.SysArea, ) }) }) group.Group("/", func(group *ghttp.RouterGroup) { group.Group("/common/file", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysFile) }) group.Group("/common/audit", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysAudit) }) group.Group("/system/config", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysConfig) }) group.Group("/user", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysUser) }) group.Group("/role", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysRole) }) group.Group("/permission", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysPermission) }) group.Group("/organization", func(group *ghttp.RouterGroup) { group.Bind(sysController.SysOrganization) }) }) }) } s.SetDumpRouterMap(true) s.Run() return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.