init.go 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. )
  8. func InitRoute(r *gin.Engine) {
  9. r.POST("/enterprise/create", handler.WrapCreateEnterpriseHandler)
  10. r.POST("/product/create", handler.WrapCreateProductHandler)
  11. r.POST("/login", handler.WrapPasswordLoginHandler)
  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. })
  36. }
  37. }