Response

router/Response~ Response

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

Constructor

new Response()

Source:
Initializes the response.

Members

_content :string

Source:
The content of response.
Type:
  • string

_cookieTransformFunction :Object

Source:
Transform function for cookie value.
Type:
  • Object

_internalCookieStorage :Map.<string, {value: string, options: {domain: string=, expires: (number|string)=}}>

Source:
Internal cookie storage for Set-Cookie header.
Type:
  • Map.<string, {value: string, options: {domain: string=, expires: (number|string)=}}>

_isSent :boolean

Source:
It is flag for sent response for request.
Type:
  • boolean

_pageState :Object.<string, *>

Source:
The rendered page state.
Type:
  • Object.<string, *>

(nullable) _response :Express.Response

Source:
The ExpressJS response object, or null if running at the client side.
Type:
  • Express.Response

_status :number

Source:
HTTP Status code.
Type:
  • number

Methods

_prepareCookieOptionsForExpress(options) → {Object}

Source:
Prepares cookie options for Express.
Parameters:
Name Type Description
options Object 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:
Cookie options prepared for Express.
Type
Object

_setCookieHeaders()

Source:
Set cookie headers for response.

getResponseParams() → {Object}

Source:
Return object which contains response status, content and rendered page state.
Returns:
Type
Object

init(responsenullable, cookieTransformFunctionopt) → {ima.router.Response}

Source:
Initializes this response wrapper with the provided ExpressJS response object.
Parameters:
Name Type Attributes Description
response Express.Response <nullable>
The ExpressJS response, or null if the code is running at the client side.
cookieTransformFunction Object <optional>
Returns:
This response.
Type
ima.router.Response

isResponseSent() → {boolean}

Source:
Return true if response is sent from server to client.
Returns:
Type
boolean

redirect(url, statusopt) → {Response}

Source:
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 Attributes Default Description
url string The URL to which the client should be redirected.
status number <optional>
302 The HTTP status code to send to the client.
Returns:
This response.
Type
Response

send(content) → {Response}

Source:
Sends the response to the client with the provided content. Use this method only at the server side.
Parameters:
Name Type Description
content string The response body.
Returns:
This response.
Type
Response

setCookie(name, value, options) → {Response}

Source:
Sets a cookie, which will be sent to the client with the response.
Parameters:
Name Type Description
name string The cookie name.
value boolean | number | string The cookie value, will be converted to string.
options Object 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.
Type
Response

setPageState(pageState) → {Response}

Source:
Sets the rendered page state.
Parameters:
Name Type Description
pageState Object.<string, *> The rendered page state.
Returns:
This response.
Type
Response

status(httpStatus) → {Response}

Source:
Sets the HTTP status code that will be sent to the client when the response is sent. For full list of available response codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html Use this method only at the server side.
Parameters:
Name Type Description
httpStatus number HTTP response status code to send to the client.
Returns:
This response.
Type
Response