Middlewares
Middlewares a functions that run before anything in the application.
For instance the one below is simply used to print the current time, it will run whatever the route.
library(ambiorix)
app <- Ambiorix$new(log = FALSE)
# middleware
app$use(\(req, res){
print(Sys.time())
})
app$get("/", \(req, res){
res$send("Using {ambiorix}!")
})
app$get("/about", \(req, res){
res$text("About")
})
app$start()