Learn R Programming

RestRserve (version 0.2.0.2)

BackendRserve: Creates Rserve backend for processing HTTP requests

Description

Creates BackendRserve object which can start Application using Rserve backend.

Arguments

Format

R6::R6Class object.

Construction

Constructor for BackendRserve.

BackendRserve$new(...)
  • ... Not used at the moment

Methods

  • start(app, http_port = 8080, ..., background = FALSE) Application, integer(1), any, logical(1) -> NULL Starts RestRserve application from current R session.

    • http_port - http port for application. Negative values (such as -1) means not to expose plain http.

    • ... - key-value pairs of the Rserve configuration. If contains "http.port" then http_port will be silently replaced with its value.

    • background - whether to try to launch in background process on UNIX systems. Ignored on windows.

  • set_request(request, path = "/", parameters_query = NULL, headers = NULL, body = NULL) :: function

    • request :: Request

    • path :: character(1) Character with requested path. Always starts with /.

    • parameters_query :: named character() A named character vector with URL decoded query parameters.

    • headers :: raw() | character(1) Request HTTP headers.

    • body :: raw() | character() Request body. Can be NULL, raw vector or named character vector for the URL encoded form (like a parameters_query parameter).

  • convert_response(response) Response -> list() Convert self object to Rserve compatible structure. According to http.c in Rserve # nolint returned list should have the following structure:

    • body: can be a character vector of length one or a raw vector. if the character vector is named "file" then the content of a file of that name is the body. If the character vector is named "tmpfile" then the content of a temporary file of that name is the body.

    • content-type: must be a character vector of length one or NULL (if present, else default is "text/plain").

    • headers: must be a character vector - the elements will have CRLF appended and neither Content-type nor Content-length may be used.

    • status-code: must be an integer if present (default is 200).