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.

37 lines
866 B

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. package cmd
  2. import (
  3. "context"
  4. "practice_Go/internal/controller/shows"
  5. "practice_Go/internal/controller/ebooks"
  6. "practice_Go/internal/controller/live_streams"
  7. "github.com/gogf/gf/v2/frame/g"
  8. "github.com/gogf/gf/v2/net/ghttp"
  9. "github.com/gogf/gf/v2/os/gcmd"
  10. )
  11. func MiddlewareCORS(r *ghttp.Request) {
  12. r.Response.CORSDefault()
  13. r.Middleware.Next()
  14. }
  15. var (
  16. Main = gcmd.Command{
  17. Name: "main",
  18. Usage: "main",
  19. Brief: "start http server",
  20. Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
  21. s := g.Server()
  22. s.Group("/api", func(group *ghttp.RouterGroup) {
  23. group.Middleware(MiddlewareCORS)
  24. group.POST("/ebooks/getEbookList", ebooks.Ebooks.GetEbooksList)
  25. group.POST("/live/getLiveList", live_streams.Live.GetLiveList)
  26. group.POST("/show/getShowList", shows.Shows.GetShowList)
  27. })
  28. s.Run()
  29. return nil
  30. },
  31. }
  32. )