{"id":13806473,"url":"https://github.com/shareed2k/fiber_limiter","last_synced_at":"2025-04-12T08:18:47.512Z","repository":{"id":75376613,"uuid":"252735920","full_name":"Shareed2k/fiber_limiter","owner":"Shareed2k","description":"fiber_limiter using redis as store for rate limit with two algorithms for choosing sliding window, gcra leaky bucket","archived":false,"fork":false,"pushed_at":"2020-05-31T10:45:05.000Z","size":25,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T08:18:40.036Z","etag":null,"topics":["fiber","fiber-framework","gcra","go-redis","golang","limiter","middleware","redis","sliding-windows"],"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-03T13:12:21.000Z","updated_at":"2024-09-10T01:56:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"302f8d39-32cb-41e5-87fb-408aeb2f2871","html_url":"https://github.com/Shareed2k/fiber_limiter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Ffiber_limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Ffiber_limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Ffiber_limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shareed2k%2Ffiber_limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shareed2k","download_url":"https://codeload.github.com/Shareed2k/fiber_limiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537192,"owners_count":21120711,"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","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":["fiber","fiber-framework","gcra","go-redis","golang","limiter","middleware","redis","sliding-windows"],"created_at":"2024-08-04T01:01:12.211Z","updated_at":"2025-04-12T08:18:47.491Z","avatar_url":"https://github.com/Shareed2k.png","language":"Go","funding_links":[],"categories":["⚙️ Middlewares"],"sub_categories":["🌱 Third Party"],"readme":"## fiber_limiter is middleware for fiber framework \n\nfiber_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 -u github.com/gofiber/fiber\ngo get -u github.com/shareed2k/fiber_limiter\n```\n### Example\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/go-redis/redis/v7\"\n\t\"github.com/gofiber/fiber\"\n\tlimiter \"github.com/shareed2k/fiber_limiter\"\n)\n\nfunc main() {\n\tapp := fiber.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\tapp.Use(limiter.New(cfg))\n\n\tapp.Get(\"/\", func(c *fiber.Ctx) {\n\t\tc.Send(\"Welcome!\")\n\t})\n\n\tapp.Listen(3000)\n}\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%2Ffiber_limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshareed2k%2Ffiber_limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshareed2k%2Ffiber_limiter/lists"}