Skip to content

Path parameters ​

@Param()은 RFC 6570 placeholder에 값을 연결합니다. 경로뿐 아니라 protocol·host·pathPrefix·path 전체에서 사용할 수 있습니다.

Example ​

ts
import { 
Get
,
JinFrame
,
Param
} from 'jin-frame';
@
Get
({
host
: '{protocol}://{tenant}.api.example.com',
pathPrefix
: '/v{version}',
path
: '/users/{id}',
}) class
UserFrame
extends
JinFrame
{
// Expand the protocol and hostname placeholders. @
Param
()
declare readonly
protocol
: 'http' | 'https';
@
Param
()
declare readonly
tenant
: string;
// Expand the shared path prefix. @
Param
()
declare readonly
version
: number;
// Map the local field name to the {id} placeholder. @
Param
({
replaceAt
: 'id' })
declare readonly
userId
: string;
} const
frame
=
UserFrame
.
of
({
protocol
: 'https',
tenant
: 'acme',
version
: 2,
userId
: 'alice',
}); // https://acme.api.example.com/v2/users/alice
console
.
log
(
frame
.
_request
().
url
);

Options ​

OptionTypeDefaultDescription
replaceAtstringfield 이름field 이름 대신 사용할 placeholder 이름입니다.
encodebooleantrue값에 URI 인코딩을 적용합니다.
commabooleanfalsearray 요소를 쉼표로 연결합니다.
bit.enablebooleanfalse숫자 array를 비트 OR 값으로 합칩니다.
bit.withZerobooleanfalse비트 OR 결과가 0이어도 포함합니다.
formattersFormatter | Formatter[]—string 직렬화 전에 값을 변환합니다.
cacheKeyExcludebooleanfalse중복 제거 키에서만 제외하며 URL에는 값을 유지합니다.

bit는 { enable: true, withZero: false } 형태로 지정합니다. formatter 설정은 formatter, URL 조합과 호출별 변경은 URL 템플릿을 참고하세요.