Learn R Programming

Rook (version 1.2)

Builder-class: Class Builder

Description

A convenience object for combining various Middleware with a default application to create a more complex Rook application.

Arguments

Methods

new(...):

Arguments can be any Middleware object while the last argument in the list must be a valid Rook application. That is, it will handle the incoming request without deferring to another application.

See Also

Rhttpd, Static, Brewery, and Redirect.

Examples

Run this code

# The following is the Hmisc example. Explore the folder
# system.file('exampleApps/Hmisc',package='Rook') for more information.
s <- Rhttpd$new()
if (FALSE) {
library(Hmisc)
dir.create(file.path(tempdir(),'plots'),showWarnings=FALSE)
s$add( name="Hmisc",
    app=Builder$new(
        Static$new(
            urls = c('/css','/images','/javascript'),
            root = system.file('exampleApps/Hmisc',package='Rook')
        ),
        Static$new(urls='/plots',root=tempdir()),
        Brewery$new(
            url='/brew',
            root= system.file('exampleApps/Hmisc',package='Rook'),
            imagepath=file.path(tempdir(),'plots'),
            imageurl='../plots/'
        ),
        Redirect$new('/brew/useR2007.rhtml')
    )
)
s$start(quiet=TRUE)
s$browse('Hmisc') # Opens a browser window to the application.
s$remove(all=TRUE)
s$stop()
}

Run the code above in your browser using DataLab