new HttpResponseTemplate()
A template for configuring client-side HTTP responses.
Methods
asJsonObject() → {HttpResponseTemplate}
Configure the template to decode the response as a Json object.
Returns:
a new
HttpResponseTemplate
instance decoding the response as a Json object
- Type
- HttpResponseTemplate
asString(encoding) → {HttpResponseTemplate}
Like HttpResponseTemplate#asString but with the specified
encoding
param.
Parameters:
Name | Type | Description |
---|---|---|
encoding |
string |
Returns:
- Type
- HttpResponseTemplate
send(handler)
Send a request, the
handler
will receive the response as an HttpResponse.
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
sendBuffer(body, handler)
Like HttpResponseTemplate#send but with an HTTP request
body
buffer.
Parameters:
Name | Type | Description |
---|---|---|
body |
Buffer | the body |
handler |
function |
sendJson(body, handler)
Like HttpResponseTemplate#send but with an HTTP request
body
json and the content type
set to application/json
.
Parameters:
Name | Type | Description |
---|---|---|
body |
Object | the body |
handler |
function |
sendStream(body, handler)
Like HttpResponseTemplate#send but with an HTTP request
body
stream.
Parameters:
Name | Type | Description |
---|---|---|
body |
ReadStream | the body |
handler |
function |