mirror of
https://github.com/tiger1103/gfast.git
synced 2026-09-22 02:27:54 +00:00
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/net/ghttp"
|
|
"github.com/gogf/gf/v2/os/gcmd"
|
|
"github.com/gogf/gf/v2/protocol/goai"
|
|
consts "github.com/tiger1103/gfast/v3/internal/const"
|
|
"github.com/tiger1103/gfast/v3/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)
|
|
})
|
|
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: consts.OpenAPIContactName,
|
|
URL: consts.OpenAPIContactUrl,
|
|
},
|
|
}
|
|
}
|