How I built a Go middleware for Stripe-style idempotency-key handling

TL;DR AI
2 min readKey summary
A Go net/http middleware called idempo was released to handle Idempotency-Key requests using Stripe-style semantics.
It atomically claims keys, stores full responses, and replays duplicates; in-flight retries get 409, and reused keys with different payloads are rejected.
The middleware follows the IETF Idempotency-Key draft and is aimed at preventing duplicate charges or side effects when clients retry timed-out API calls.
It supports multiple backends, including in-memory, Redis, and Postgres, and can be used with routers like chi.
