Skip to main content

Module reqctx

Module reqctx 

Source
Expand description

Request Context on the wire (parser ADR 0014): the typed fields an app declares, which travel with a request to every call made for it.

A field is one header, x-encore-meta-ctx-<name>, holding its JSON value base64url-encoded without padding: a value may be non-ASCII, and a header value read as anything but visible ASCII is read differently by every HTTP library. On a Pub/Sub message, the attribute encore-ctx-<name> holds the same encoding.

Fields are call metadata like the caller and the user: every entry point strips them from what it is sent, and a call’s signature covers them (crate::svcauth). Their sizes are checked where a field is set, by the SDKs, against MAX_FIELD_SIZE and MAX_FIELDS_SIZE, so a value too big fails the code that made it rather than a later hop’s header limits.

Structs§

DecodeError
A field value that is not base64url without padding.

Constants§

ATTRIBUTE_PREFIX
The Pub/Sub attribute name prefix of a Request Context field on a message published with it set: the field’s name follows it.
HEADER_PREFIX
The header name prefix of a Request Context field: the field’s name follows it.
MAX_FIELDS_SIZE
The most bytes all of a request’s fields’ encoded values may have together: 8 KiB, half of the 16 KiB Node’s HTTP server takes of a request’s headers in all by default, leaving the rest to the request.
MAX_FIELD_SIZE
The most bytes one field’s encoded value may have: 4 KiB, well within nginx’s 8 KiB for a header line.

Functions§

decode
The JSON value encoded holds, as encode wrote it.
encode
json, a field’s JSON value, as its header and attribute hold it.
field_of
The field a header carries, when header (lowercase, as HTTP libraries hold names) is a Request Context header.
header_name
The header carrying the field name.
is_field_header
Whether header (lowercase) is a Request Context header.
valid_name
Whether name is a valid field name: kebab-case as the parser has it for every resource, 1 to 63 lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit.