# init responsers = Response$new()# set body media typers$set_content_type("text/plain")# set body contentrs$set_body("OK")# set response status coders$set_status_code(200L)# print responsers
# init responsers = Response$new()# static file pathfile_path = system.file("DESCRIPTION", package ="RestRserve")# get last file modification timestampfile_mtime = file.mtime(file_path)# set bodyrs$set_body(c("file"= file_path))# set content typers$set_content_type("text/plain")# set current timestamprs$set_date()# set 'last-modified' headerrs$set_header("Last-Modified", as(file_mtime,"HTTPDate"))# print responsers
See Also
Request Application
Public fields
body: Response body.
If it is a named character with a name `file` or `tmpfile`
then the value is considered as a path to a file and content oh this file is served as body. The latter will be deleted once served.
content_type: Response body content (media) type. Will be translated to Content-type header.
headers: Response headers.
status_code: Response HTTP status code.
cookies: Response cookies. Will be translated to Set-Cookie headers.
context: Environment to store any data. Can be used in middlewares.
encode: Function to encode body for specific content.
Active bindings
status: Paste together status code and description.