package cmd import ( "aiChat/internal/controller" "aiChat/internal/middleware" "context" "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: "aiChat", Usage: "main", Brief: "start http aiChat server", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { s := g.Server() s.Use(middleware.MiddlewareHandlerResponse) s.Use(middleware.MiddlewareHandlerSession) s.Group("/aiChat", func(group *ghttp.RouterGroup) { group.ALL("/ws", controller.ChatWs) //websocket 聊天 group.Bind( controller.ChatHistory, //历史记录 controller.Evaluate, //评价 controller.GuessQuestion, //猜你想问 controller.UsuallyProblem, //常见问题 ) }) s.Run() return nil }, } )