apply_plumber2_block: Generic for applying information from a plumber2 block to an...

View source: R/parse_plumber_file.R

apply_plumber2_blockR Documentation

Generic for applying information from a plumber2 block to an api

Description

In order to facilitate extensibility of the plumber2 file syntax you can provide your own methods for how to apply information from a plumber2 block to an api.

Usage

apply_plumber2_block(block, api, route_name, root, ...)

Arguments

block

The block that was parsed

api

The Plumber2 api object to apply it to

route_name

The name of the route the plumber2 file is associated with. Either the name of the file or the value of the ⁠@routeName⁠ tag

root

The root given by the potential ⁠@root⁠ tag in the file. If no ⁠@root⁠ tag is present this value will be null. The value represents the root path for every endpoint defined in the file and should be prepended to any URL path you use.

...

ignored

Value

api, modified

See Also

add_plumber2_tag()

Examples

# Add a method for a fictional "hello_block" that makes the api say hello when
# it starts
apply_plumber2_block.hello_block <- function(block, api, route_name, root, ...) {
  api$on("start", function(...) {
    message("Hello")
  })
  api
}


plumber2 documentation built on Jan. 20, 2026, 5:06 p.m.