route.go 870 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package route
  4. import (
  5. "net/http"
  6. "github.com/gin-gonic/gin"
  7. "access-control-monitor/controller/v1"
  8. _ "access-control-monitor/docs"
  9. )
  10. func SetupRoute(engine *gin.Engine) {
  11. // 404页面
  12. engine.NoRoute(func(c *gin.Context) {
  13. c.String(http.StatusNotFound, "Not Found")
  14. })
  15. c := v1.NewController()
  16. // 服务健康检查
  17. engine.PUT("/ping", c.Ping)
  18. // version 1
  19. apiv1 := engine.Group("/api/v1")
  20. {
  21. apiv1.PUT("/auth", c.Auth)
  22. apiv1.PUT("/attendance", c.Attendance)
  23. team := apiv1.Group("/team")
  24. {
  25. team.POST("", c.TeamInfoAdd)
  26. team.PUT("", c.TeamUpdate)
  27. team.PUT("/del", c.TeamDelete)
  28. }
  29. staff := apiv1.Group("/staff")
  30. {
  31. staff.POST("", c.Register)
  32. staff.PUT("", c.StaffUpdate)
  33. staff.PUT("/del", c.StaffDelete)
  34. }
  35. }
  36. }