2022-10-14 09:15:43 +00:00
|
|
|
package middleware
|
|
|
|
|
2023-02-17 15:36:54 +00:00
|
|
|
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"
|
2023-02-17 15:36:54 +00:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
2022-10-14 09:15:43 +00:00
|
|
|
|
2023-02-17 15:36:54 +00:00
|
|
|
func SearchLimit(num int64) func(ctx *gin.Context) {
|
2022-11-16 03:09:25 +00:00
|
|
|
fn, reFn := IpLimit(num)
|
2024-01-24 07:13:29 +00:00
|
|
|
reload.Append(func() {
|
2023-02-17 15:36:54 +00:00
|
|
|
reFn(config.GetConfig().SingleIpSearchNum)
|
2024-01-24 07:13:29 +00:00
|
|
|
}, "search-ip-limit-number")
|
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()
|
|
|
|
}
|
|
|
|
|
2023-02-17 15:36:54 +00:00
|
|
|
}
|
2022-10-14 09:15:43 +00:00
|
|
|
}
|