Server: Server class

ServerR Documentation

Server class

Description

The package is based on httpuv::. It is designed to host static resources such as html, javascript, css, etc along with specific route requests to perform various R based actions or respond with various content(i.g. JSON strings, images, etc). The server is designed to work in a local host environment (i.e. url = 127.0.0.1) as part of an html/javascript project that needs a link to R language capabilities and its associated packages.

Details

Class provides an http server that connects R language resources with javascript applications.

Public fields

index_path

A string that defines the full directory path to an index.html file defining the server's root path (i.e. "\"). The root html file is assumed to be named "index.html".

port

An integer that defines the port number for the server. The default is 8080.

routes

A vector of RserverPkg::Route objects that define the request paths that the server will respond to. Each RserverPkg::Route object should define the path, callback function that optionally returns content, and the content's MIME content type. The callback function can be defined to receive a RserverPkg::Request object argument.

static_paths

A named list that defines the locations of static resources (.css, .html, .js files) for hosting by the server. The list name is the web path (e.g. "/content") and the value is the full directory path to the resources (e.g. F:/web_server/content).

Methods

Public methods


Method new()

Defines the classes' public fields

Usage
Server$new(index_path = NULL, port = 8080, routes = NULL, static_paths = NULL)
Arguments
index_path

A string that defines the full directory path to an index.html file defining the server's root path (i.e. "\").

port

An integer that defines the port number for the server.

routes

A vector of RserverPkg::Route objects that define the request paths that the server will respond to.

static_paths

A named list that defines the locations of static resources (.css, .html, .js files) for hosting by the server.


Method start()

Start the server

Usage
Server$start()

Method stop()

Stop the server

Usage
Server$stop()

Method list_servers()

List the current servers

Usage
Server$list_servers()

Method clone()

The objects of this class are cloneable with this method.

Usage
Server$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Rick Dean


deandevl/RserverPkg documentation built on June 9, 2022, 9:44 p.m.