router.go 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package api
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // RegRouters 注册路由
  7. func RegRouters(svc *Service) {
  8. boxcost := svc.NewGinRouter("/" + svc.Conf.Name)
  9. boxcost.group.Use(Logger())
  10. boxcost.GET("/printr", Printr)
  11. // 材料管理
  12. Material(boxcost)
  13. // 工艺管理
  14. Craft(boxcost)
  15. // 工序管理
  16. Process(boxcost)
  17. // 供应商管理
  18. Supplier(boxcost)
  19. // 供应商价格管理
  20. SupplierPrice(boxcost)
  21. // 包装管理
  22. Pack(boxcost)
  23. // 生产计划管理
  24. ProductPlan(boxcost)
  25. // 单据管理
  26. Bill(boxcost)
  27. //设置
  28. Setting(boxcost)
  29. }
  30. func Logger() gin.HandlerFunc {
  31. return func(c *gin.Context) {
  32. // 开始时间
  33. // start := time.Now()
  34. // 处理请求
  35. c.Next()
  36. // 结束时间
  37. // end := time.Now()
  38. //执行时间
  39. // latency := end.Sub(start)
  40. path := c.Request.URL.Path
  41. clientIP := c.ClientIP()
  42. // method := c.Request.Method
  43. // statusCode := c.Writer.Status()
  44. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  45. fmt.Println(out)
  46. }
  47. }