Response {beakr} | R Documentation |
Response Class
Description
A Response
object represents represents the HTTP response that a
Beakr
sends when it gets an HTTP request. It is by convention, the
object is always referred to as res
(and the HTTP request is
req
).
Fields
headers
-
A list containing a key-value header list.
status
-
An integer HTTP status code.
body
-
Contains the response body.
Methods
setHeader(key, value)
-
Sets a key-value header, i.e.
"Content-Type" = "text/html"
. setContentType(type)
-
Sets the response content-type.
setStatus(status)
-
Sets the HTTP status code.
setBody(body)
-
Sets the body response.
redirect(url)
-
Sets the HTTP status to 302, "Found" and redirects to
url
. json(txt, auto_unbox = TRUE)
-
Applies a function to text convert to JSON and sets the content-type to JSON.
text(txt)
-
Sets the response body text.
structured(protocol)
-
Sets the response protocol, i.e. "http"
plot(plot_object, base64 = TRUE, ...)
-
Sets the response type to plot image output.
Methods
Public methods
Method setHeader()
Usage
Response$setHeader(key, value)
Method setContentType()
Usage
Response$setContentType(type)
Method setStatus()
Usage
Response$setStatus(status)
Method setBody()
Usage
Response$setBody(body)
Method redirect()
Usage
Response$redirect(url)
Method json()
Usage
Response$json(txt, auto_unbox = TRUE)
Method text()
Usage
Response$text(txt)
Method structured()
Usage
Response$structured(protocol)
Method plot()
Usage
Response$plot(plot_object, base64 = TRUE, ...)
Method clone()
The objects of this class are cloneable with this method.
Usage
Response$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.