I am struggling to find a solution that httr can do the same thing as plumber in R. In plumber here's the code that works:
1). Create a script hello_world_plumber.R
#' @post /hello_world
hi <- function(name) {
return(paste0('Hello ', name, '!'))
}
2). In another script:
pr <- plumb(file = '~/hello_world_plumber.R')
pr$run(swagger = F)
Starting server to listen on port 5852
Running the swagger UI at http://127.0.0.1:5852/__swagger__/
3). In the terminal
curl -s --data 'Matt' http://127.0.0.1:5852/hello_world
Out: Hello Matt!