package cmd import ( "context" "net/http" "practice_ArticleVote_Go/internal/controller/article" vr "practice_ArticleVote_Go/internal/controller/vote_record" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gcmd" ) 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.Use(func(r *ghttp.Request) { r.Response.CORSDefault() if r.Method == http.MethodOptions { r.Response.WriteStatus(http.StatusOK) return } r.Middleware.Next() }) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(ghttp.MiddlewareHandlerResponse) group.Bind(article.ArticleController) }) s.Group("/vote", func(group *ghttp.RouterGroup) { group.Middleware(ghttp.MiddlewareHandlerResponse) group.Bind( vr.NewV1(), ) }) s.Run() return nil }, } )