UNPKG

@aws-amplify/core

Version:
1 lines 1.63 kB
{"version":3,"file":"amzSdkInvocationIdHeaderMiddleware.mjs","sources":["../../../../../src/clients/middleware/retry/amzSdkInvocationIdHeaderMiddleware.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { amplifyUuid } from '../../../libraryUtils';\nimport { AMZ_SDK_INVOCATION_ID_HEADER } from './constants';\n/**\n * Middleware injects a UUID string to `amz-sdk-invocation-id` header.\n * if the header is not set already. This header is helpful to provide\n * observability to group the requests caused by automatic retry.\n *\n * This middleware is standalone because of extra UUID dependency, we will\n * NOT use this middleware for API categories.\n *\n * Ref: https://sdk.amazonaws.com/kotlin/api/smithy-kotlin/api/1.0.9/http-client/aws.smithy.kotlin.runtime.http.operation/-http-operation-context/-sdk-invocation-id.html\n */\nexport const amzSdkInvocationIdHeaderMiddlewareFactory = () => next => {\n return async function amzSdkInvocationIdHeaderMiddleware(request) {\n if (!request.headers[AMZ_SDK_INVOCATION_ID_HEADER]) {\n request.headers[AMZ_SDK_INVOCATION_ID_HEADER] = amplifyUuid();\n }\n return next(request);\n };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,yCAAyC,GAAG,MAAM,IAAI,IAAI;AACvE,IAAI,OAAO,eAAe,kCAAkC,CAAC,OAAO,EAAE;AACtE,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,EAAE;AAC5D,YAAY,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,WAAW,EAAE;AACzE;AACA,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC;AAC5B,KAAK;AACL;;;;"}