diff --git a/go.mod b/go.mod index 28fef5f..020cfc3 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,9 @@ module backend go 1.23.1 require ( + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/go-chi/chi/v5 v5.1.0 // indirect + github.com/go-chi/httprate v0.14.1 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/lmittmann/tint v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index 4216455..0967e69 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/httprate v0.14.1 h1:EKZHYEZ58Cg6hWcYzoZILsv7ppb46Wt4uQ738IRtpZs= +github.com/go-chi/httprate v0.14.1/go.mod h1:TUepLXaz/pCjmCtf/obgOQJ2Sz6rC8fSf5cAt5cnTt0= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/lmittmann/tint v1.0.5 h1:NQclAutOfYsqs2F1Lenue6OoWCajs5wJcP3DfWVpePw= diff --git a/internal/server/router.go b/internal/server/router.go index 91857f6..928b90a 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -8,6 +8,7 @@ import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" + "github.com/go-chi/httprate" "backend/internal/handler" ) @@ -21,6 +22,7 @@ func NewRouter() { r.Use(middleware.Logger) r.Use(middleware.Recoverer) r.Use(middleware.Timeout(60 * time.Second)) + r.Use(httprate.LimitByRealIP(32, time.Minute)) r.Get("/", func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "https://axolotlmaid.com", http.StatusPermanentRedirect)