Rook (version 1.1-1)

RhttpdApp-class: Class RhttpdApp

Description

Creates a Rook application ready to add to an Rhttpd server.

Arguments

Methods

new(app, name):

Creates an object of class RhttpdApp. Argument app can be any Rook aware object or it can be a location to a file whose source creates a Rook aware object. That object must be named either 'app' or the value of name. name is a character vector.

Details

The internal web server allows dispatching to user-defined closures located in tools:::.httpd.handlers.env. For instance, if a handler named 'foo' is placed there, then the url path to that handler is /custom/foo.

RhttpdApp along with Rhttpd hide these details by allowing a user to create application objects specifying only their name and the application. There is currently a limit of 63 characters or less for application names.

NOTE: When a file is given as the value of the app argument to new(), it is monitored for timestamp changes. If a change occurs in the modification time as returned by file.info, then the file is sourced prior to handling subsequent requests.

See Also

Rhttpd.

Examples

Run this code

s <- Rhttpd$new()
s$add(RhttpdApp$new(
    name='summary',
    app=system.file('exampleApps/summary.R',package='Rook')
))
if (FALSE) {
s$start(quiet=TRUE)
s$browse(1)
}
s$remove(all=TRUE)

#  Stops the server but doesn't uninstall the app
if (FALSE) {
s$stop()
}
s$remove(all=TRUE)
rm(s)

Run the code above in your browser using DataCamp Workspace