httpGET {beakr} | R Documentation |
GET-binding middleware
Description
Routes HTTP GET requests to the specified path with the specified callback functions or middleware.
Usage
httpGET(beakr, path = NULL, FUN = NULL)
Arguments
beakr |
|
path |
String representing a path for which the middleware function is invoked. |
FUN |
Middleware function to be invoked. |
Value
A Beakr
instance with added middleware.
Examples
## Not run:
library(beakr)
# Create an new Beakr instance
beakr <- newBeakr()
# Create a simple beakr pipeline
beakr %>%
httpGET("/", function(req, res, err) {
return("Successful GET request!\n")
}) %>%
listen(host = '127.0.0.1', port = 25118, daemon = TRUE)
# ------------------------------------------------------------
# IN A TERMINAL:
# curl -X GET http://127.0.0.1:25118/
# > Successful GET request!
# ------------------------------------------------------------
# Stop the beakr instance server
stopServer(beakr)
## End(Not run)
[Package beakr version 0.4.3 Index]