Skip to content

Commit

Permalink
Remove rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
codemicro committed Mar 20, 2024
1 parent a797e8f commit 7abf5f6
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions internal/httpcore/httpcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/bwmarrin/go-alone"
validate "github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
g "github.com/maragudk/gomponents"
"github.com/maragudk/gomponents/html"
"log/slog"
Expand Down Expand Up @@ -73,30 +72,6 @@ func ListenAndServe(ctx context.Context, addr string) error {
return ctx.Next()
})

app.Use(limiter.New(limiter.Config{
Next: func(ctx *fiber.Ctx) bool {
p := ctx.Path()
// Perform path checks here to avoid doing database calls (in getSessionAuth) if not completely neccessary.
if p == "/" || urlFileRegexp.MatchString(p) {
return true
}

_, authStatus := getSessionAuth(ctx)
return authStatus == authNotAuthed
},
Max: 45,
KeyGenerator: func(ctx *fiber.Ctx) string {
// only set if authed, which we are if it's passed the Next check
return ctx.Locals("token").(string)
},
LimitReached: func(ctx *fiber.Ctx) error {
return &fiber.Error{
Code: fiber.StatusTooManyRequests,
Message: "Slow down!",
}
},
}))

app.Get("/auth/login", e.authLoginPage)
app.Post("/auth/login", e.authLoginPage)
app.Get(loginActionEndpoint, e.authLogin)
Expand Down

0 comments on commit 7abf5f6

Please sign in to comment.