route_stack: Combine routes in a stack

View source: R/tidy_api.R

route_stackR Documentation

Combine routes in a stack

Description

This function allows you to combine multiple routes into a stack in order to dispatch on them until one of them returns FALSE. This allows you to have a router that can pass a request through multiple handlers before sending it along to the client or other middleware

Usage

route_stack(x, ...)

## Default S3 method:
route_stack(x, ...)

## S3 method for class 'Route'
route_stack(x, ...)

## S3 method for class 'AssetRoute'
route_stack(x, ...)

## S3 method for class 'RouteStack'
route_stack(x, ..., .after = NULL)

Arguments

x

A Route or RouteStack object

...

one or more named Route objects

.after

Where in the stack should the new routes be placed. NULL means place them at the end.

Value

A RouteStack object. If x is a RouteStack then this will be returned, modified.

Examples


# Create an empty route stack
route_stack()

# Stack a route with another, returning a RouteStack
route(all = list("*" = function(...) TRUE)) |>
  route_stack(
    limit = sizelimit_route()
  )


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