To use this function, write the endpoint somewhere and then copy it into clipboard. Then call this function. This function uses clipr to write it to the 'plumber.R' file. For now only file will be plumber.R

gp_endpoint_from_clip(evaluate = FALSE)

Arguments

evaluate

extra check on clipboard content

Value

None

Details

TODO: add silent param, write to other .R files.

Examples

if (FALSE) { # Following is a valid endpoint to serve geoplumber::traffic dataset: # = begin ===> # Serve geoplumber::traffic from /api/data # @get /api/data # get_traffic <- function(res) { # geojson <- geojsonio::geojson_json(geoplumber::traffic) # res$body <- geojson # res # } # <==== end = # holindg current clipboard old_clip <- clipr::read_clip() # adding above to clipboard clipr::write_clip(c( "#' Serve geoplumber::traffic from /api/data", "@get /api/data", "get_traffic <- function(res) {", "geojson <- geojsonio::geojson_json(geoplumber::traffic)", "res$body <- geojson", "res", "}" )) # clipr::read_clip() gp_endpoint_from_clip() clipr::write_clip(old_clip) }