Skip to content

allow custom method in option to extract idempotency-key #26

@mahendraHegde

Description

@mahendraHegde

while idempotency-key is typically found in header, in some cases, it is better to allow application developer to decide where to get the key from.

acceptance criteria

  • add an optional parameter idempotencyKeyExtractor to options
  • its a method and
    - takes RequestWithDefaults as args similar to skipRequest
    - return string | undefined

and then use options or use default implementation from here:

private getIdempotencyKey(
req: IdempotencyParamsWithDefaults,
): string | undefined {
const key = Object.keys(req.headers).find(
(key) => key.toLowerCase() === req.options.idempotencyKey.toLowerCase(),
);
return key ? (req.headers[key] as string) : undefined;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions