{"id":24440640,"url":"https://github.com/furkandeveloper/idempotency-middleware","last_synced_at":"2026-02-16T20:34:25.785Z","repository":{"id":273250342,"uuid":"915809940","full_name":"furkandeveloper/idempotency-middleware","owner":"furkandeveloper","description":"The idempotency-middleware library adds idempotency support to your Go API projects. It ensures that a client request is processed only once, regardless of how many times it is received. This middleware is especially useful for handling retry logic in distributed systems.","archived":false,"fork":false,"pushed_at":"2025-01-19T19:29:55.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T05:18:57.079Z","etag":null,"topics":["idempotency","idempotency-support","idempotent","idempotent-requests"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furkandeveloper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-12T21:19:58.000Z","updated_at":"2025-01-19T19:29:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a616c44-4c67-403d-8177-5fd6b3733fc8","html_url":"https://github.com/furkandeveloper/idempotency-middleware","commit_stats":null,"previous_names":["furkandeveloper/idempotency-middleware"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/furkandeveloper/idempotency-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkandeveloper%2Fidempotency-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkandeveloper%2Fidempotency-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkandeveloper%2Fidempotency-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkandeveloper%2Fidempotency-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furkandeveloper","download_url":"https://codeload.github.com/furkandeveloper/idempotency-middleware/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furkandeveloper%2Fidempotency-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29517613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T18:37:19.720Z","status":"ssl_error","status_checked_at":"2026-02-16T18:36:46.920Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["idempotency","idempotency-support","idempotent","idempotent-requests"],"created_at":"2025-01-20T20:56:51.950Z","updated_at":"2026-02-16T20:34:25.767Z","avatar_url":"https://github.com/furkandeveloper.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/449d7dd6-ae6a-4c52-92ef-bdbe962f1215\" style=\"max-width:100%;\" height=\"300\" /\u003e\n\u003c/p\u003e\n\n## Give a Star 🌟\nIf you liked the project or if **idempotency-middleware** helped you, please give a star.\n\n## Overview\n\nThe `idempotency-middleware` library adds idempotency support to your Go API projects. It ensures that a client request is processed only once, regardless of how many times it is received. This middleware is especially useful for handling retry logic in distributed systems.\n\n## Features\n\n- Easy-to-configure idempotency mechanism using Redis.\n\n- Customizable options such as header key and expiration time.\n\n- Seamless integration with the Echo framework.\n\n## Requirements\n\n- Go 1.23.4 or later\n\n- Redis\n\n- Echo v4\n\n## Installation\n\nAdd the library to your project using `go get`:\n\n```bash\ngo get github.com/furkandeveloper/idempotency-middleware\n```\n\nEnsure the dependencies in your `go.mod` file include:\n\n\n```go\nmodule your-module-name\n\nrequire (\n    github.com/furkandeveloper/idempotency-middleware latest\n)\n```\n\n## Usage\n### Configuration\n\nUse the `LoadConfig` function to load the configuration for Redis and the idempotency middleware.\n\n```go\ncfg := pkg.LoadConfig(1, \"X-Request-Id\")\n```\n\n**Expiration Time**: Specify the idempotency key expiration time in minutes.\n\n**Header Key**: Define the HTTP header used to identify the idempotency key.\n\n### Initialize Redis Client\n\nCreate a Redis client using the loaded configuration:\n\n```go\nredisClient := pkg.NewClient(cfg.Redis)\n```\n\n### Middleware Setup\n\nCreate an instance of the idempotency middleware:\n\n```go\nidempotencyMiddleware := pkg.NewIdempotencyMiddleware(redisClient, pkg.Option(cfg.Idempotency))\n```\n\n### Apply Midlleware To Routes\n\n```go\npackage main\n\nimport (\n\t\"github.com/furkandeveloper/idempotency-middleware/pkg\"\n\t\"github.com/labstack/echo/v4\"\n\t\"github.com/labstack/echo/v4/middleware\"\n)\n\nfunc ExampleHandler(c echo.Context) error {\n\treturn c.JSON(200, map[string]string{\"message\": \"Request processed successfully!\"})\n}\n\nfunc ExampleHandlerWithoutIdempotency(c echo.Context) error {\n\treturn c.JSON(200, map[string]string{\"message\": \"No idempotency applied.\"})\n}\n\nfunc main() {\n\tcfg := pkg.LoadConfig(1, \"X-Request-Id\")\n\n\tredisClient := pkg.NewClient(cfg.Redis)\n\n\te := echo.New()\n\te.Use(middleware.Logger())\n\te.Use(middleware.Recover())\n\n\tidempotencyMiddleware := pkg.NewIdempotencyMiddleware(redisClient, pkg.Option(cfg.Idempotency))\n\n\te.GET(\"/no-middleware\", ExampleHandlerWithoutIdempotency)\n\te.GET(\"/with-middleware\", ExampleHandler, idempotencyMiddleware)\n\n\te.Logger.Fatal(e.Start(\":8080\"))\n}\n\n```\n\n### How It Works\n\n- Request Header: The client sends a unique token in the header (e.g., X-Request-Id).\n- Redis Check: The middleware checks Redis for an existing response for the given token.\n- Process:\n    -  If a response exists, it is returned directly.\n    - If not, the request is processed, and the response is cached in Redis.\n- Cache Expiry: Responses are stored in Redis for the configured expiration time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkandeveloper%2Fidempotency-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurkandeveloper%2Fidempotency-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurkandeveloper%2Fidempotency-middleware/lists"}