wp-go/internal/middleware/searchlimit.go

23 lines
405 B
Go
Raw Permalink Normal View History

2022-10-14 09:15:43 +00:00
package middleware
import (
"github.com/fthvgb1/wp-go/internal/cmd/reload"
"github.com/fthvgb1/wp-go/internal/pkg/config"
"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
}