2026-04-18 05:44:10 -06:00
2026-04-18 05:44:10 -06:00
2026-04-18 05:43:08 -06:00
2026-04-13 23:06:50 +00:00
2026-04-13 23:06:50 +00:00
2026-04-18 05:28:10 -06:00

echo-ratelimit

Small in-memory rate-limiting middleware for Echo, keyed by client IP.

Install

go get git.carlpearson.net/cwpearson/echo-ratelimit@latest

Usage

package main

import (
	"net/http"
	"time"

	"github.com/labstack/echo/v4"

	ratelimit "git.carlpearson.net/cwpearson/echo-ratelimit"
)

func main() {
	e := echo.New()
	e.Use(ratelimit.Middleware(60, time.Minute))

	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "ok")
	})

	e.Logger.Fatal(e.Start(":8080"))
}

Custom Configuration

e.Use(ratelimit.WithConfig(ratelimit.Config{
	Limit:      10,
	Window:     time.Minute,
}))

Rate-limit headers are emitted by default.

Description
No description provided
Readme 33 KiB
Languages
Go 100%