123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package api
- import (
- "fmt"
- "github.com/gin-gonic/gin"
- )
- // RegRouters 注册路由
- func RegRouters(svc *Service) {
- //登录
- spud3dGroup := svc.NewGinRouter("/" + svc.Conf.Name)
- spud3dGroup.group.Use(Logger())
- RegQueenMats(spud3dGroup)
- // 模型库
- RegQueenMeshes(spud3dGroup)
- RegQueenterApi(spud3dGroup)
- RegQueenterUploadApi(spud3dGroup)
- CreateDatabaseCategoryRouter(spud3dGroup)
- //数据存储
- // spud3dGroup.POST("/save/policy", UploadPolicy)
- // spud3dGroup.GETJWT("/obs/list", ServiceObsList)
- // spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy)
- // spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove)
- // spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder)
- }
- func Logger() gin.HandlerFunc {
- return func(c *gin.Context) {
- // 开始时间
- // start := time.Now()
- // 处理请求
- c.Next()
- // 结束时间
- // end := time.Now()
- //执行时间
- // latency := end.Sub(start)
- path := c.Request.URL.Path
- clientIP := c.ClientIP()
- // method := c.Request.Method
- // statusCode := c.Writer.Status()
- out := fmt.Sprintf("%15s=> %s", clientIP, path)
- fmt.Println(out)
- }
- }
|