1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package cmd
- import (
- "context"
- "github.com/gogf/gf/v2/frame/g"
- "github.com/gogf/gf/v2/net/ghttp"
- "github.com/gogf/gf/v2/net/goai"
- "github.com/gogf/gf/v2/os/gcmd"
- "nodeMonitor/internal/consts"
- "nodeMonitor/internal/router"
- )
- var (
- Main = gcmd.Command{
- Name: "main",
- Usage: "main",
- Brief: "start http server",
- Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
- s := g.Server()
- s.Group("/", func(group *ghttp.RouterGroup) {
- router.BindController(group)
- })
- // Custom enhance API document.
- enhanceOpenAPIDoc(s)
- s.Run()
- return nil
- },
- }
- )
- func enhanceOpenAPIDoc(s *ghttp.Server) {
- openapi := s.GetOpenApi()
- openapi.Config.CommonResponse = ghttp.DefaultHandlerResponse{}
- openapi.Config.CommonResponseDataField = `Data`
- // API description.
- openapi.Info = goai.Info{
- Title: consts.OpenAPITitle,
- Description: consts.OpenAPIDescription,
- Contact: &goai.Contact{
- Name: "GoFrame",
- URL: "https://goframe.org",
- },
- }
- }
|