Members
writeStreamLineHandler :function
Command streaming interceptor handler.
isStreaming :boolean
Indicates if the response is currently streaming.
Methods
prepareHandling(app, request, response)
Prepare request handling.
Parameters:
Name | Type | Description |
---|---|---|
app |
container.Container | The current container instance. |
request |
request | The current request instance. |
response |
response | The current response instance. |
view(view, data)
Send HTML response.
Parameters:
Name | Type | Description |
---|---|---|
view |
string | The view name. |
data |
* | The view-model data. |
Returns:
The response instance.
- Type
- response
json(object)
Send JSON response.
Parameters:
Name | Type | Description |
---|---|---|
object |
string | number | boolean | object | The JSON value to send. |
Returns:
The response instance.
- Type
- response
dump(…parameters)
Dump parameters in the current response.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
parameters |
* |
<repeatable> |
The dumped values. |
(async) stream(handler)
Send a stream response.
Ends the request when the handler resolves.
Parameters:
Name | Type | Description |
---|---|---|
handler |
function | The stream handler. |
Returns:
The async process promise.
- Type
- Promise
writeStreamLine(line)
Write line in the stream response.
Parameters:
Name | Type | Description |
---|---|---|
line |
string | The line to stream into the response. |
Returns:
The current controller instance.
streamCommand(command)
Send a stream response from command output.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | Array.<string> | The command string. |
Returns:
The async process promise.
- Type
- Promise
(async) runCommand(command, handleropt)
Run command.
Handle output if an handler is provided.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
command |
string | Array.<string> | The command string. | ||
handler |
function | null |
<optional> |
null
|
The handler that will received printed data after command will have run. |
Returns:
The async process promise.
- Type
- Promise
validate(validationClosure)
Validate the current request body against the given schema.
Parameters:
Name | Type | Description |
---|---|---|
validationClosure |
function | The validation callback that returns the validation schema. |
redirect(to, permanentopt)
Redirect to the given URL with the appropriate redirection code.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
to |
string | The URL to redirect to. | ||
permanent |
boolean |
<optional> |
false
|
Indicates that the redirection response should flag a permanent redirection. |
Returns:
The current response instance.
- Type
- response
permanentRedirect(to)
Redirect to the given URL permanently.
Parameters:
Name | Type | Description |
---|---|---|
to |
string | The URL to redirect to. |
Returns:
The current response instance.
- Type
- response
status(status)
Set response status.
Parameters:
Name | Type | Description |
---|---|---|
status |
number | The HTTP status code. |
Returns:
The current controller instance.
throwWithStatus(status)
Set response status and throw an HTTP error that reflects the given status.
Parameters:
Name | Type | Description |
---|---|---|
status |
number | The HTTP status code. |
Throws:
-
The corresponding HTTP error based on the HTTP status code.
ok()
Set 200 OK status.
Returns:
The current controller instance.
created()
Set 201 Created status.
Returns:
The current controller instance.
accepted()
Set 202 Accepted status.
Returns:
The current controller instance.
noContent()
Set 204 No Content status.
Returns:
The current controller instance.
badRequest()
Set 400 Bad Request status.
Returns:
The current controller instance.
unauthorized()
Set 401 Unauthorized status.
Returns:
The current controller instance.
forbidden()
Set 403 Forbidden status.
Returns:
The current controller instance.
notFound()
Set 404 Not Found status.
Returns:
The current controller instance.
methodNotAllowed()
Set 405 Method Not Allowed status.
Returns:
The current controller instance.
timeout()
Set 408 Timeout status.
Returns:
The current controller instance.
teapot()
Set 418 I'm A Teapot status.
Returns:
The current controller instance.