Brewery-class function

Class Brewery

Class Brewery

A Middleware class for mapping URLs to a directory of files that are subsequently passed to brew. When a file is brewed, the two variables req (an object of class Request) and res (an object of class Response) are available for use. 1.1

class

Methods

  • new(url,root,...):: url is a character string or regexp on which to match, root is the name of the directory where brew files reside. Named arguments can be passed in via ... and will be available within the scope of each brewed file.

Examples

# # This application runs any file found in tempdir() through brew. # s <- Rhttpd$new() ## Not run: s$start(quiet=TRUE) ## End(Not run) cat("<h1>Random Number: <%=rnorm(1)%></h1>", file=file.path(tempdir(),"index.html")) s$add(name="random", app=Builder$new( Brewery$new(url="/",root=tempdir()), Redirect$new("/index.html") ) ) ## Not run: s$browse('random') # Opens a browser window to the app. ## End(Not run) file.remove(file.path(tempdir(),"index.html")) s$remove(all=TRUE) rm(s)

See Also

Rhttpd, Builder, Redirect, and brew.

  • Maintainer: Evan Biederstedt
  • License: GPL-2
  • Last published: 2022-11-07