View Source IdempotencyPlug (TestServer v0.1.0)

Plug that handles Idempotency-Key HTTP headers.

A single Idempotency-Key HTTP header is required for POST and PATCH requests.

Handling of requests is based on https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/

request-id

Request ID

The value of the Idempotency-Key HTTP header is combined with an URI to produce a unique ID for the request. This will be used to store the response for first-time request. The ID is used to fetch this response in all subsequent requests.

A fingerprint of the request payload is generated, and used to ensure the ID is not reused with a different request payload.

error-handling

Error handling

  • Concurrent requests will return a 409 Conflict response.
  • Mismatch of request payload fingerprint will return 422 Unprocessable Entity response.
  • If the first-time request was unexpectedly terminated a 500 Internal Server is returned.

Cached responses and halted first-time requests, returns an Expires header in the response.

See IdempotencyPlug.RequestTracker for more on expiration.

options

Options

examples

Examples

plug IdempotencyPlug,
  tracker: IdempotencyPlug.RequestTracker,
  handler: IdempotencyPlug.Handler