Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mahendraHegde opened this issue Mar 28, 2024 · 0 comments
Open

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

mahendraHegde opened this issue Mar 28, 2024 · 0 comments
Labels
core good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mahendraHegde
Copy link
Owner

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;
}

@mahendraHegde mahendraHegde added help wanted Extra attention is needed good first issue Good for newcomers core labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant