mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
remove api ratelimiter
This commit is contained in:
parent
4775f4ea31
commit
01357617ae
1 changed files with 1 additions and 16 deletions
|
@ -8,8 +8,6 @@ import (
|
|||
"github.com/yusing/go-proxy/internal/api/v1/auth"
|
||||
. "github.com/yusing/go-proxy/internal/api/v1/utils"
|
||||
"github.com/yusing/go-proxy/internal/common"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/net/http/middleware"
|
||||
)
|
||||
|
||||
type ServeMux struct{ *http.ServeMux }
|
||||
|
@ -19,7 +17,7 @@ func NewServeMux() ServeMux {
|
|||
}
|
||||
|
||||
func (mux ServeMux) HandleFunc(method, endpoint string, handler http.HandlerFunc) {
|
||||
mux.ServeMux.HandleFunc(method+" "+endpoint, checkHost(rateLimited(handler)))
|
||||
mux.ServeMux.HandleFunc(method+" "+endpoint, checkHost(handler))
|
||||
}
|
||||
|
||||
func NewHandler() http.Handler {
|
||||
|
@ -58,16 +56,3 @@ func checkHost(f http.HandlerFunc) http.HandlerFunc {
|
|||
f(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
func rateLimited(f http.HandlerFunc) http.HandlerFunc {
|
||||
m, err := middleware.RateLimiter.New(middleware.OptionsRaw{
|
||||
"average": 10,
|
||||
"burst": 10,
|
||||
})
|
||||
if err != nil {
|
||||
logging.Fatal().Err(err).Msg("unable to create API rate limiter")
|
||||
}
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
m.ModifyRequest(f, w, r)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue