File size: 357 Bytes
4e23b01
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import { parseOrGenerateRequestId } from './protocol/request-id';

const REQUEST_ID_HEADER = 'x-request-id';

export function resolveRequestId(
  headers: Record<string, string | string[] | undefined>,
): string {
  const raw = headers[REQUEST_ID_HEADER];
  const supplied = Array.isArray(raw) ? raw[0] : raw;
  return parseOrGenerateRequestId(supplied);
}