Skip to content

Headers ​

@Header() maps fields to outgoing HTTP headers. Use replaceAt to specify the header name.

Example ​

ts
import { 
Get
,
JinFrame
,
Header
} from 'jin-frame';
@
Get
({
host
: 'https://api.example.com',
path
: '/me',
}) class
ExampleFrame
extends
JinFrame
{
// Map a convenient field name to its HTTP header name. @
Header
({
replaceAt
: 'X-Request-Id' })
declare readonly
requestId
: string;
@
Header
({
replaceAt
: 'Accept-Language' })
declare readonly
language
?: string;
} // Build the request without contacting the placeholder server. const
frame
=
ExampleFrame
.
of
({
requestId
: 'request-123',
language
: 'en' });
const
request
=
frame
.
_request
();
console
.
log
(
request
.
headers
);

Options ​

OptionTypeDefaultDescription
replaceAtstringField nameDestination name instead of the field name.
encodebooleantrueApply URI encoding to the value.
commabooleanfalseJoin array elements with commas.
bit.enablebooleanfalseCombine numeric arrays using bitwise OR.
bit.withZerobooleanfalseInclude a bitwise result even when it is zero.
formattersFormatter | Formatter[]undefinedTransform values before serialization.
cacheKeyExcludebooleanfalseExclude from dedupe identity without removing the transmitted value.

Configure bit as { enable: true, withZero: false }.

Header names and values ​

replaceAt chooses the wire name; the field remains a typed factory input. Optional absent fields are omitted. comma, bit, and formatters are available for API-specific serialization, but an HTTP header is not a nested JSON object.

Authentication and browser restrictions ​

An explicit Authorization header bypasses security providers. Avoid unintentionally overriding constructor token suppliers with a decorated header. Browsers can restrict headers such as Cookie and User-Agent; CORS and browser rules still apply.

Do not set multipart Content-Type manually: native FormData supplies its boundary. cacheKeyExclude should not hide user identity in a request that may share results across callers.