Description Methods See Also Examples
A Rook
application that maps url paths to other Rook
applications.
new(...)
: Creates a Rook
application. All arguments must be Rook
applications and named as in the example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.