microserver_response: Simple S3 class to denote JSON responses for httupv.

Description Usage Arguments Examples

View source: R/response.r

Description

Simple S3 class to denote JSON responses for httupv.

Usage

1
2
microserver_response(response = NULL, status = 200,
  headers = list(`content-type` = "text/json"))

Arguments

response

ANY. The R object to send as a response parameter. If the header is set to text/json it will be converted into a JSON string.

status

integer. HTTP status (default is 200).

headers

list. A list of HTTP headers (default is list('Content-Type' = 'text/json').

Examples

1
2
3
4
5
## Not run: 
response('Did not work!', 404) # 404 error
response(list(a = 1, b = 2))   # { "a": 1, "b": 2 } JSON response

## End(Not run)

dvanderbeek/microserver-test documentation built on May 21, 2019, 8:37 a.m.