diff --git a/app/mw/mw_limiter.go b/app/mw/mw_limiter.go index 8dd62f9..d777bde 100644 --- a/app/mw/mw_limiter.go +++ b/app/mw/mw_limiter.go @@ -16,7 +16,7 @@ func Limiter(c *gin.Context) { limit := 500 // 限流次数 ttl := 2 // 限流过期时间 ip := utils.GetIP(c.Request) - if ip != "221.4.210.167" { + if ip != "221.4.210.167" && c.Request.Host != "127.0.0.1:4000" { e.OutErr(c, e.ERR, "系统维护中~") return } @@ -34,8 +34,8 @@ func Limiter(c *gin.Context) { // Write body back c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body)) utils.FilePutContents("Limiter", utils.SerializeStr(map[string]interface{}{ - "uri": c.Request.URL, - "body": c.Request.Body, + "uri": c.Request.URL.Path, + "body": string(bytes.NewBuffer(body).Bytes()), })) //queryValue := utils.SerializeStr(c.Request.URL.Query()) //不建议开启,失去限流的意义 diff --git a/app/router/router.go b/app/router/router.go index 076a733..c771fa7 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -63,8 +63,8 @@ func route(r *gin.RouterGroup) { rCallback.Any("/alipay/face", hdl.CallbackAlipayFace) //支付宝实名回调 } - r.Use(mw.Limiter) //进行限流 r.Use(mw.CheckSign) + r.Use(mw.Limiter) //进行限流 r.Any("/testCreateSign", hdl.TestCreateSign) r.GET("/openApp/start", hdl.Start) //打开app调用 r.GET("/config", hdl.Config) //基本配置