# Simple GET handler
h1 <- handler("/hello", function(req) {
list(status = 200L, body = "Hello!")
})
# POST handler that echoes the request body
h2 <- handler("/echo", function(req) {
list(status = 200L, body = req$body)
}, method = "POST")
# Catch-all handler for a path prefix
h3 <- handler("/static", function(req) {
# Serve static files under /static/*
}, method = "*", prefix = TRUE)
Run the code above in your browser using DataLab