api {occupationMeasurement} | R Documentation |
Start the occupation coding API.
Description
Start the occupation coding API.
Usage
api(
start = TRUE,
log_to_file = FALSE,
file = system.file("plumber", "api", "plumber.R", package = "occupationMeasurement"),
log_to_console = TRUE,
log_filepath = file.path("output", "log_api.csv"),
require_identifier = FALSE,
allow_origin = NULL
)
Arguments
start |
Whether to immediately start the api. (Defaults to TRUE) |
log_to_file |
Whether to requests should be logged in a file. Defaults to FALSE. Note: The file format used here is a CSV file for easier analysis. |
file |
Path to the |
log_to_console |
Whether to requests should be logged in the console. Defaults to TRUE. |
log_filepath |
The path to a CSV file in which to save the structured logs. |
require_identifier |
Whether an identifier has to be added to api requests in order to match / identify requests afterwards. Defaults to FALSE. |
allow_origin |
Domain from which to allow cross origin requests (CORS). If the API is running on a different domain / server than the application using it, the website's root has to be provided here e.g. "https://occupationMeasurement.github.io". For more information see the plumber security page, and MDN. Defaults to NULL to not set any header at all. |
Value
A Plumber router
See Also
vignette("api")
Examples
if (interactive()) {
# Get the plumber router
router <- api(
start = FALSE,
# If this is TRUE, the log directory will immediately be created
log_to_file = FALSE
)
# Start the router
plumber::pr_run(router)
}
if (interactive()) {
# Immediately start the API
api(start = TRUE)
}