beakr (version 0.3.1)

httpPUT: PUT-binding middleware

Description

Routes HTTP PUT requests to the specified path with the specified callback functions or middleware.

Usage

httpPUT(beakr, path = NULL, FUN = NULL)

Arguments

beakr

Beakr instance or NULL.

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

Run this code
# NOT RUN {
# Create an new Beakr instance
beakr <- newBeakr()

# Create a simple beakr pipeline
beakr %>%
  httpPUT("/", function(req, res, err) {
    return("Successful PUT request!\n")
  }) %>%
  listen(host = '127.0.0.1', port = 25118, daemon = TRUE)

# ------------------------------------------------------------
# IN A TERMINAL:
#  curl -X PUT http://127.0.0.1:25118/
# > Successful PUT request!
# ------------------------------------------------------------

# Stop the beakr instance server
stopServer(beakr)
# }

Run the code above in your browser using DataLab