Skip to contents

This function allows you to combine two separate routes into one. This is different from combining them in a routestack, because a request is only matched to one handler in each route (thus combining them with route_merge() will ensure only one handler is called).

Usage

route_merge(x, route, use_root = TRUE)

Arguments

x, route

Route objects to merge. route will be merged into x

use_root

Should the root of route be added to all its paths before it is merged into x

Value

x with route merged into it

Examples

route() |>
  route_add("HEAD", "*", function(...) {
    message("Someone's looking")
    TRUE
  }) |>
  route_merge(
    sizelimit_route()
  )
#> A route with 2 handlers
#> Warning: first element used of 'length.out' argument
#> head:
#> • *
#> all:
#> • *