URLMap-class function

Class URLMap

Class URLMap

A Rook application that maps url paths to other Rook applications. 1.1

class

See Also

Rhttpd.

Examples

s <- Rhttpd$new() s$add( name="pingpong", app=Rook::URLMap$new( '/ping' = function(env){ req <- Rook::Request$new(env) res <- Rook::Response$new() res$write(sprintf('<h1><a href="%s">Pong</a></h1>',req$to_url("/pong"))) res$finish() }, '/pong' = function(env){ req <- Rook::Request$new(env) res <- Rook::Response$new() res$write(sprintf('<h1><a href="%s">Ping</a></h1>',req$to_url("/ping"))) res$finish() }, '/?' = function(env){ req <- Rook::Request$new(env) res <- Rook::Response$new() res$redirect(req$to_url('/pong')) res$finish() } ) ) ## Not run: s$start(quiet=TRUE) s$browse('pingpong') ## End(Not run) s$remove('pingpong') ## Not run: s$stop() ## End(Not run) rm(s)

Methods

  • new(...):: Creates a Rook application. All arguments must be Rook applications and named as in the example.
  • Maintainer: Evan Biederstedt
  • License: GPL-2
  • Last published: 2022-11-07