Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Main = gcmd.Command{ Name: "gf2-demo-api", Brief: "An API Server Demo", Description: "An API server demo using GoFrame V2", Usage: "gf2-demo-api [OPTION]", Examples: ` Dev: ./gf2-demo-api Test: ./gf2-demo-api -c config.test.yaml or GF_GCFG_FILE=config.test.yaml GF_GERROR_BRIEF=true ./gf2-demo-api Prod: ./gf2-demo-api -c config.prod.yaml or GF_GCFG_FILE=config.prod.yaml GF_GERROR_BRIEF=true ./gf2-demo-api`, Additional: "Find more information at: https://github.com/windvalley/gf2-demo", Arguments: []gcmd.Argument{ { Name: "version", Short: "v", Brief: "print version info", IsArg: false, Orphan: true, }, { Name: "config", Short: "c", Brief: "config file (default config.yaml)", IsArg: false, Orphan: false, }, }, Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { ver := parser.GetOpt("version") if ver != nil { utility.PrintVersionInfo() return nil } config := parser.GetOpt("config").String() if config != "" { g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetFileName(config) } logFormat, err := g.Cfg().Get(ctx, "logger.format") if err == nil { if logFormat.String() == "json" { glog.SetDefaultHandler(glog.HandlerJson) } } g.Log().SetFlags(glog.F_ASYNC | glog.F_TIME_STD | glog.F_FILE_LONG) configFile := g.Cfg().GetAdapter() g.Log().Debugf(ctx, "use config file: %+v", configFile) s := g.Server() s.Use( service.Middleware().TraceID, service.Middleware().AccessUser, service.Middleware().ResponseHandler, ) s.Group("/v1", func(group *ghttp.RouterGroup) { group.Bind( demo.NewV1(), ) }) s.Run() return nil }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.