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§
- Decode
Error - 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
encodedholds, asencodewrote 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
nameis 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.