library(RestRserve)
app = Application$new()
app$add_get("/foo", FUN = function(.req, .res) {
# since .res is a dummy instance of Response class
# exported by RestRserve
# IDE facilitates with autocompletion!
.res$set_body("bar")
# in the same time all the modifications happen with local objects
# so you get right results in the end
})
response = app$process_request(Request$new(path = "/foo"))
response$body
Run the code above in your browser using DataLab