Endpoint.renderPath()method
Render the path for this endpoint with the given payload.
renderPath(payload: P, caller: AnyCaller = this.renderPath): AbsolutePath
new Endpoint<P, R>(method: RequestMethod, path: AbsolutePath, payload: Schema<P>, result: Schema<R>)
| Param | Type | |
|---|---|---|
method | RequestMethod | The method of the endpoint, e.g. GET required |
path | AbsolutePath | Endpoint path, possibly including placeholders e.g. /users/{id} required |
payload | Schema<P> | A Schema for the payload of the endpoint. required |
result | Schema<R> | A Schema for the result of the endpoint. required |
| Return | |
|---|---|
Endpoint<P, R> | A typed API resource definition pairing a method and path with payload and result schemas. |
| Property | Type | |
|---|---|---|
.method | RequestMethod | |
.path | AbsolutePath | Endpoint path, possibly including placeholders e.g. /users/{id} required readonly |
.placeholders | TemplatePlaceholders | The {placeholder} segments extracted from path, used to render and match URLs. required readonly |
.payload | Schema<P> | |
.result | Schema<R> |
A typed API resource definition pairing a method and path with payload and result schemas.
{placeholder} segments that are filled from the payload at request time.const getUser = new Endpoint("GET", "/users/{id}", USER_PAYLOAD, USER_RESULT);Render the path for this endpoint with the given payload.
renderPath(payload: P, caller: AnyCaller = this.renderPath): AbsolutePath
Match a method/path pair against this endpoint and return any matched {placeholder} params.
match(method: RequestMethod, path: AbsolutePath, caller: AnyCaller = this.match): RequestParams | undefined
Create an endpoint handler pairing for this endpoint.
handler(callback: EndpointCallback<P, R, C>): EndpointHandler<P, R, C>
Convert this endpoint to a string in METHOD /path form, e.g. GET /user/{id}
toString(): string