Learn R Programming

plumber2 (version 0.2.0)

parse_plumber_file: Parse a plumber file

Description

This function takes care of parsing an annotated plumber file and creating one or more routes, API specs, and a modifier function to be called on the plumber app after the routes have been added. This function does not attach the parsed data to a plumber api, and it is rarely necessary to call it directly.

Usage

parse_plumber_file(path, env = caller_env())

Value

A list containing:

  • route The main route handling requests according to the parsed file, as a named list of length one

  • header_route The route to be attached to header events (fires before the body has been received and can be used to prematurely reject requests based on their headers), as a named list of length one

  • asset_routes All the asset routes created by @static blocks as a named list

  • message_handlers All the websocket message handlers created by @message blocks, as a list

  • api A list giving the OpenAPI spec as parsed from the file

  • modifier A single function chaining all the functions from @plumber blocks together

Arguments

path

The path to the file to parse

env

The environment to evaluate the code and annotations in

Examples

Run this code
if (FALSE) { # file.exists("path/to/my/plumber/file.R")
# Parse a plumber file
parse_plumber_file("path/to/my/plumber/file.R")
}

Run the code above in your browser using DataLab