inst/plumber.R

#
# This is a Plumber API. In RStudio 1.2 or newer you can run the API by
# clicking the 'Run API' button above.
#
# In RStudio 1.1 or older, see the Plumber documentation for details
# on running the API.
#
# Find out more about building APIs with Plumber here:
#
#    https://www.rplumber.io/
#

library("plumber")
library("plumber.pack")

#* @apiTitle Plumber Example API

#* Hello World / plumber.pack version
#* @get /
function() {
  endpoint_home()
}

#* Echo back the input
#* @param msg The message to echo
#* @get /echo
function(msg=""){
  endpoint_echo(msg)
}

#* Plot a histogram
#* @png
#* @get /plot
function(){
  rand <- rnorm(100)
  hist(rand)
}

#* Return the sum of two numbers
#* @param a The first number to add
#* @param b The second number to add
#* @post /sum
function(a, b){
  as.numeric(a) + as.numeric(b)
}
andybega/plumber.pack documentation built on Jan. 15, 2020, 12:20 a.m.