{"id":18700163,"url":"https://github.com/shareed2k/echo_limiter","last_synced_at":"2025-09-08T18:37:56.401Z","repository":{"id":64306190,"uuid":"252793121","full_name":"Shareed2k/echo_limiter","owner":"Shareed2k","description":"echo_limiter using redis as store for rate limit with two algorithms for choosing sliding window, gcra leaky bucket","archived":false,"fork":false,"pushed_at":"2023-08-31T08:12:28.000Z","size":18,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T08:18:41.057Z","etag":null,"topics":["echo","echo-framework","gcra","golang","rate-limiting","redis","sliding-window"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shareed2k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-03T17:09:55.000Z","updated_at":"2025-01-27T04:39:13.000Z","dependencies_parsed_at":"2024-06-20T04:38:38.689Z","dependency_job_id":"e94434e0-ba0b-4165-b74b-3effbb93b9e0","html_url":"https://github.com/Shareed2k/echo_limiter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Shareed2k/echo_limiter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fecho_limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fecho_limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fecho_limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fecho_limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shareed2k","download_url":"https://codeload.github.com/Shareed2k/echo_limiter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Fecho_limiter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229384,"owners_count":25245189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["echo","echo-framework","gcra","golang","rate-limiting","redis","sliding-window"],"created_at":"2024-11-07T11:36:02.581Z","updated_at":"2025-09-08T18:37:56.343Z","avatar_url":"https://github.com/Shareed2k.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## echo_limiter is middleware for echo framework \n\necho_limiter using [redis](https://github.com/go-redis/redis) as store for rate limit with two algorithms for choosing sliding window, gcra [leaky bucket](https://en.wikipedia.org/wiki/Leaky_bucket)\n\n### Install\n```\ngo get github.com/shareed2k/echo_limiter\n```\n### Example\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/go-redis/redis/v7\"\n\t\"github.com/labstack/echo/v4\"\n\tlimiter \"github.com/shareed2k/echo_limiter\"\n)\n\nfunc main() {\n\te := echo.New()\n\n\toption, err := redis.ParseURL(\"redis://127.0.0.1:6379/0\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tclient := redis.NewClient(option)\n\t_ = client.FlushDB().Err()\n\n\t// 3 requests per 10 seconds max\n\tcfg := limiter.Config{\n\t\tRediser:   client,\n\t\tMax:       3,\n\t\tBurst:     3,\n\t\tPeriod:    10 * time.Second,\n\t\tAlgorithm: limiter.GCRAAlgorithm,\n\t}\n\n\te.Use(limiter.NewWithConfig(cfg))\n\n\te.GET(\"/\", func(c echo.Context) error {\n\t\treturn c.String(http.StatusOK, \"Hello, World!\")\n\t})\n\te.Logger.Fatal(e.Start(\":3000\"))\n}\n```\n### Test\n```curl\ncurl http://localhost:3000\n...\n\u003c HTTP/1.1 200 OK\n\u003c Date: Fri, 03 Apr 2020 13:02:02 GMT\n\u003c Content-Type: text/plain; charset=utf-8\n\u003c Content-Length: 8\n\u003c X-Ratelimit-Limit: 3\n\u003c X-Ratelimit-Remaining: 2\n\u003c X-Ratelimit-Reset: 1585918925\n...\n\ncurl http://localhost:3000\ncurl http://localhost:3000\ncurl http://localhost:3000\n\n...\n\u003c HTTP/1.1 429 Too Many Requests\n\u003c Date: Fri, 03 Apr 2020 13:02:29 GMT\n\u003c Content-Type: text/plain; charset=utf-8\n\u003c Content-Length: 42\n\u003c Retry-After: 1585918951\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshareed2k%2Fecho_limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshareed2k%2Fecho_limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshareed2k%2Fecho_limiter/lists"}