Learn R Programming

routr (version 1.0.0)

route: Construct a new route

Description

This function constructs a new Route, optionally with a set of handlers already attached.

Usage

route(..., root = "")

Value

A Route object

Arguments

...

Handlers to add up front. Must be in the form of named lists where the names corresponds to paths and the elements are the handlers. The name of the argument itself defines the method to listen on (see examples)

root

The root of the route. Will be removed from the path of any request before matching a handler

Examples

Run this code
# An empty route
route <- route()
route

# Prepopulating it at construction
route <- route(all = list(
  '/*' = function(request, response, keys, ...) {
    message('Request received')
    TRUE
  }
))
route

Run the code above in your browser using DataLab