Route: Construct a new route

routeR Documentation

Construct a new route

Description

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

Usage

route(..., root = "")

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

Value

A Route object

Examples

# An empty route
route <- route()
route

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


thomasp85/routr documentation built on April 13, 2025, 10:36 a.m.