init.go 1.1 KB

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