View source: R/endpoint_from_clip.R
gp_endpoint_from_clip | R Documentation |
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)
evaluate |
extra check on clipboard content |
TODO: add silent param, write to other .R files.
None
## Not run:
# 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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.