app = Application$new(middleware = list(CORSMiddleware$new()))
app$add_post(path = "/hello", FUN = function(req, res) {
res$set_body("Hello from RestRserve!")
})
app$add_route("/hello", method = "OPTIONS", FUN = function(req, res) {
res$set_header("Allow", "POST, OPTIONS")
})
req = Request$new(
path = "/hello",
headers = list("Access-Control-Request-Method" = "POST"),
method = "OPTIONS"
)
app$process_request(req)
Run the code above in your browser using DataLab