Skip to main content

Class: Response

@ima/core.Response

Wrapper for the ExpressJS response, exposing only the necessary minimum.

Constructors

constructor

new Response()

Properties

_cookieTransformFunction

Protected _cookieTransformFunction: CookieTransformFunction

Transform function for cookie value.

Defined in

packages/core/src/router/Response.ts:35


_internalCookieStorage

Protected _internalCookieStorage: Map<string, { options: CookieOptions ; value: string }>

Internal cookie storage for Set-Cookie header.

Defined in

packages/core/src/router/Response.ts:27


_internalHeadersStorage

Protected _internalHeadersStorage: UnknownParameters = {}

Defined in

packages/core/src/router/Response.ts:31


_response

Protected Optional _response: Response<any, Record<string, any>>

The ExpressJS response object, or undefined if running at the client side.

Defined in

packages/core/src/router/Response.ts:23

Accessors

$dependencies

Static get $dependencies(): never[]

Returns

never[]

Defined in

packages/core/src/router/Response.ts:40

Methods

getResponseParams

getResponseParams(): Object

Return object which contains response headers and cookie.

Returns

Object

NameType
cookieMap<string, { options: CookieOptions ; value: string }>
headersUnknownParameters

Defined in

packages/core/src/router/Response.ts:172


init

init(response, cookieTransformFunction?): Response

Initializes this response wrapper with the provided ExpressJS response object.

Parameters

NameTypeDescription
responseResponse<any, Record<string, any>>The ExpressJS response, or null if the code is running at the client side.
cookieTransformFunctionObject-

Returns

Response

This response.

Defined in

packages/core/src/router/Response.ts:53


redirect

redirect(url, options?): void

Redirects the client to the specified location, with the specified redirect HTTP response code.

For full list of HTTP response status codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Use this method only at the server side.

Parameters

NameTypeDescription
urlstringThe URL to which the client should be redirected. @param[status=302] The HTTP status code to send to the client.
optionsPartial<RouteOptions>-

Returns

void

This response.

Defined in

packages/core/src/router/Response.ts:80


setCookie

setCookie(name, value, options?): Response

Sets a cookie, which will be sent to the client with the response.

Parameters

NameTypeDescription
namestringThe cookie name.
valuestring | number | booleanThe cookie value, will be converted to string.
optionsCookieOptionsCookie attributes. Only the attributes listed in the type annotation of this field are supported. For documentation and full list of cookie attributes see http://tools.ietf.org/html/rfc2965#page-5

Returns

Response

This response.

Defined in

packages/core/src/router/Response.ts:117


setHeader

setHeader(name, value): Response

Sets a header, which will be sent to the client with the response.

Parameters

NameTypeDescription
namestringThe header name.
valueunknownThe header value, will be

Returns

Response

This response.

Defined in

packages/core/src/router/Response.ts:153