コンテンツにスキップ
日本語

requestIdOf

このコンテンツはまだ日本語訳がありません。

requestIdOf(request, headerName?): string | undefined

Defined in: src/http/middleware/RequestId.ts:32

The request id request carries, or undefined when it carries none — or when what it carries is not a well-formed id.

The check is the reason this is a function rather than a header read at the call site: the value is client-controlled, and raw client bytes on a log line can forge whole log records through an embedded newline. It is the same check the middleware applies before echoing an incoming id into a response header, deliberately shared rather than re-derived.

What comes back is what the request claimed, which is what correlation needs — with trustIncoming: false the middleware will have generated a different id for everything downstream of it, so a caller that logs this should name the header it came from rather than present it as the id.

HttpRequest

string = DEFAULT_REQUEST_ID_HEADER

string | undefined