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
Name | Type |
---|---|
cookie | Map <string , { options : CookieOptions ; value : string }> |
headers | UnknownParameters |
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
Name | Type | Description |
---|---|---|
response | Response <any , Record <string , any >> | The ExpressJS response, or null if the code is running at the client side. |
cookieTransformFunction | Object | - |
Returns
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
Name | Type | Description |
---|---|---|
url | string | The URL to which the client should be redirected. @param[status=302] The HTTP status code to send to the client. |
options | Partial <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
Name | Type | Description |
---|---|---|
name | string | The cookie name. |
value | string | number | boolean | The cookie value, will be converted to string. |
options | CookieOptions | Cookie 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
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
Name | Type | Description |
---|---|---|
name | string | The header name. |
value | unknown | The header value, will be |
Returns
This response.