wp-go/app/middleware/searchlimit.go

23 lines
393 B
Go
Raw Permalink Normal View History

2022-10-14 09:15:43 +00:00
package middleware
import (
2023-05-04 12:36:17 +00:00
"github.com/fthvgb1/wp-go/app/pkg/config"
2023-11-12 13:39:04 +00:00
"github.com/fthvgb1/wp-go/cache/reload"
"github.com/gin-gonic/gin"
)
2022-10-14 09:15:43 +00:00
func SearchLimit(num int64) func(ctx *gin.Context) {
2022-11-16 03:09:25 +00:00
fn, reFn := IpLimit(num)
reload.Push(func() {
reFn(config.GetConfig().SingleIpSearchNum)
})
2022-10-14 09:15:43 +00:00
return func(c *gin.Context) {
2022-10-17 12:04:29 +00:00
if c.Query("s") != "" {
2022-10-14 09:15:43 +00:00
fn(c)
} else {
c.Next()
}
}
2022-10-14 09:15:43 +00:00
}