router.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package api
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // RegRouters 注册路由
  7. func RegRouters(svc *Service) {
  8. //登录
  9. spud3dGroup := svc.NewGinRouter("/" + svc.Conf.Name)
  10. spud3dGroup.group.Use(Logger())
  11. RegQueenMats(spud3dGroup)
  12. // 模型库
  13. RegQueenMeshes(spud3dGroup)
  14. RegQueenterApi(spud3dGroup)
  15. RegQueenterUploadApi(spud3dGroup)
  16. CreateDatabaseCategoryRouter(spud3dGroup)
  17. //数据存储
  18. // spud3dGroup.POST("/save/policy", UploadPolicy)
  19. // spud3dGroup.GETJWT("/obs/list", ServiceObsList)
  20. // spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy)
  21. // spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove)
  22. // spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder)
  23. }
  24. func Logger() gin.HandlerFunc {
  25. return func(c *gin.Context) {
  26. // 开始时间
  27. // start := time.Now()
  28. // 处理请求
  29. c.Next()
  30. // 结束时间
  31. // end := time.Now()
  32. //执行时间
  33. // latency := end.Sub(start)
  34. path := c.Request.URL.Path
  35. clientIP := c.ClientIP()
  36. // method := c.Request.Method
  37. // statusCode := c.Writer.Status()
  38. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  39. fmt.Println(out)
  40. }
  41. }