Response 

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

Kind: global class


new Response() 

Initializes the response.


response._response : Express.Response 

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

Kind: instance property of Response


response._isSent : boolean 

It is flag for sent response for request.

Kind: instance property of Response


response._status : number 

HTTP Status code.

Kind: instance property of Response


response._content : string 

The content of response.

Kind: instance property of Response


response._pageState : Object.<string, \*> 

The rendered page state.

Kind: instance property of Response


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

Internal cookie storage for Set-Cookie header.

Kind: instance property of Response


response._cookieTransformFunction : Object 

Transform function for cookie value.

Kind: instance property of Response


response.init(response, [cookieTransformFunction]) ⇒ ima.router.Response 

Initializes this response wrapper with the provided ExpressJS response object.

Kind: instance method of Response
Returns: ima.router.Response - This response.

Param Type Description
response Express.Response The ExpressJS response, or null if the code is running at the client side.
[cookieTransformFunction] Object  

response.redirect(url, [status]) ⇒ Response 

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.

Kind: instance method of Response
Returns: Response - This response.

Param Type Default Description
url string   The URL to which the client should be redirected.
[status] number 302 The HTTP status code to send to the client.

response.status(httpStatus) ⇒ Response 

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.

Kind: instance method of Response
Returns: Response - This response.

Param Type Description
httpStatus number HTTP response status code to send to the client.

response.send(content) ⇒ Response 

Sends the response to the client with the provided content. Use this method only at the server side.

Kind: instance method of Response
Returns: Response - This response.

Param Type Description
content string The response body.

response.setPageState(pageState) ⇒ Response 

Sets the rendered page state.

Kind: instance method of Response
Returns: Response - This response.

Param Type Description
pageState Object.<string, \*> The rendered page state.

response.setCookie(name, value, options) ⇒ Response 

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

Kind: instance method of Response
Returns: Response - This response.

Param 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

response.getResponseParams() ⇒ Object 

Return object which contains response status, content and rendered page state.

Kind: instance method of Response


response.isResponseSent() ⇒ boolean 

Return true if response is sent from server to client.

Kind: instance method of Response


response._setCookieHeaders() 

Set cookie headers for response.

Kind: instance method of Response


response._prepareCookieOptionsForExpress(options) ⇒ Object 

Prepares cookie options for Express.

Kind: instance method of Response
Returns: Object - Cookie options prepared for Express.

Param 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