You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. package cmd
  2. import (
  3. "context"
  4. "practice_Go/internal/controller/channel"
  5. "practice_Go/internal/controller/live"
  6. "practice_Go/internal/controller/reservation"
  7. "practice_Go/internal/controller/subscription"
  8. "github.com/gogf/gf/v2/frame/g"
  9. "github.com/gogf/gf/v2/net/ghttp"
  10. "practice_Go/internal/controller/clubPage"
  11. "practice_Go/internal/controller/mainPage"
  12. "github.com/gogf/gf/v2/os/gcmd"
  13. )
  14. var (
  15. Main = gcmd.Command{
  16. Name: "main",
  17. Usage: "main",
  18. Brief: "start http server",
  19. Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
  20. s := g.Server()
  21. s.Group("/", func(group *ghttp.RouterGroup) {
  22. group.Middleware(ghttp.MiddlewareHandlerResponse)
  23. group.Bind(
  24. channel.NewV1(),
  25. subscription.NewV1(),
  26. live.NewV1(),
  27. reservation.NewV1(),
  28. )
  29. })
  30. // 定义一个路由组,路径为/mainpage
  31. s.Group("/mainpage", func(group *ghttp.RouterGroup) {
  32. // 添加中间件,用于处理响应
  33. group.Middleware(ghttp.MiddlewareHandlerResponse)
  34. // 绑定路由,将mainPage.NewMainPage()绑定到该路由组
  35. group.Bind(
  36. mainPage.NewMainPage(),
  37. )
  38. })
  39. // 定义一个路由组,路径为/clubpage
  40. s.Group("/clubpage", func(group *ghttp.RouterGroup) {
  41. // 添加中间件,用于处理响应
  42. group.Middleware(ghttp.MiddlewareHandlerResponse)
  43. // 绑定路由,将mainPage.NewMainPage()绑定到该路由组
  44. group.Bind(
  45. clubPage.NewClubPage(),
  46. )
  47. })
  48. //开启静态资源
  49. s.SetServerRoot("resource/public")
  50. s.SetOpenApiPath("/api.json") //启用OpenAPIv3,并设置OpenAPI文档的路径
  51. s.SetSwaggerPath("/swagger") //启用内置的Swagger接口文档UI,并设置Swagger文档的路径
  52. s.Run()
  53. return nil
  54. },
  55. }
  56. )