Module: skyring/lib/server/response

Simple wrapper around the http response object to avoid deopts


new (require("skyring/lib/server/response"))(res)

Parameters:
Name Type Description
res ServerResponse

A ServerResponse from the node http module

Source:

Requires

  • module:debug

Methods


end( [chunk])

Ends the response

Parameters:
Name Type Argument Description
chunk String <optional>

An optional chunk to write be for closing the stream

Source:
Returns:
Type
module:skyring/lib/server/response

error(err [, msg])

Responsible for returning a response in the case of an error If the error has a message, it will be sent with the x-skyring-reason http header if the error has a statusCode property, that will be used, otherwise a 500 will be returned

Parameters:
Name Type Argument Description
err Error | number

The error to handle

msg String <optional>

In the case err is a number, this will be used as the message

Source:

get(header)

Returns the value of a response header

Parameters:
Name Type Description
header String

The name of the header to get

Source:
Returns:

The header value, if it is set

Type
String

json(body)

Helper for responding with an Object. Will serialize the object, and set the Content-Type header to application/json

Parameters:
Name Type Description
body Object

The object to set as the response body

Source:
Returns:
Type
module:skyring/lib/server/response

send( [chunk])

Writes a chunk to the response stream

Parameters:
Name Type Argument Description
chunk String <optional>

The chunk to write

Source:
Returns:
Type
module:skyring/lib/server/response

set(header, The)

Sets a response header

Parameters:
Name Type Description
header String

The header to set

The String

header value to set

Source:
Returns:
Type
module:skyring/lib/server/response

status(code)

Sets the status code on the response object

Parameters:
Name Type Description
code Number

The http Status code to set

Source:
Returns:
Type
module:skyring/lib/server/response