init.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package route
  2. import (
  3. "youngee_b_api/handler"
  4. "youngee_b_api/middleware"
  5. "github.com/gin-gonic/gin"
  6. "github.com/sirupsen/logrus"
  7. )
  8. func InitRoute(r *gin.Engine) {
  9. r.POST("/register", handler.WrapRegisterHandler)
  10. r.POST("/sendCode", handler.WrapSendCodeHandler)
  11. r.POST("/login", handler.WrapCodeLoginHandler)
  12. //r.GET("/test/ping", func(c *gin.Context) {
  13. // resp := http_model.CommonResponse{
  14. // Status: 0,
  15. // Message: "",
  16. // Data: "ping",
  17. // }
  18. // c.JSON(200, resp)
  19. //})
  20. //r.Any("/testDemo", func(c *gin.Context) {
  21. // resp := http_model.CommonResponse{
  22. // Status: 0,
  23. // Message: "",
  24. // Data: "pong",
  25. // }
  26. // c.JSON(200, resp)
  27. // // 注意这里只是debug用的 接口要写成handler形式
  28. //})
  29. m := r.Group("/youngee/m")
  30. {
  31. m.Use(middleware.LoginAuthMiddleware)
  32. m.POST("/test", func(c *gin.Context) {
  33. c.JSON(200, "ok")
  34. // 注意这里只是debug用的 接口要写成handler形式
  35. auth := middleware.GetSessionAuth(c)
  36. logrus.Infof("auth:%+v", auth)
  37. })
  38. m.POST("/product/findall", handler.WrapFindAllProductHandler)
  39. m.POST("/product/find", handler.WrapFindProductHandler)
  40. m.POST("/project/create", handler.WrapCreateProjectHandler)
  41. m.POST("/product/create", handler.WrapCreateProductHandler)
  42. }
  43. }