init.go 1.3 KB

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