Public methods
Method new()
Usage
Routing$new(path = "")
Arguments
pathPrefix path.
Details
Initialise
Method get()
Usage
Routing$get(path, handler, error = NULL)
Arguments
pathRoute to listen to, : defines a parameter.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
GET Method
Add routes to listen to.
Examples
app <- Ambiorix$new()
app$get("/", function(req, res){
res$send("Using {ambiorix}!")
})
if(interactive())
app$start()
Method put()
Usage
Routing$put(path, handler, error = NULL)
Arguments
pathRoute to listen to, : defines a parameter.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
PUT Method
Add routes to listen to.
Method patch()
Usage
Routing$patch(path, handler, error = NULL)
Arguments
pathRoute to listen to, : defines a parameter.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
PATCH Method
Add routes to listen to.
Method delete()
Usage
Routing$delete(path, handler, error = NULL)
Arguments
pathRoute to listen to, : defines a parameter.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
DELETE Method
Add routes to listen to.
Method post()
Usage
Routing$post(path, handler, error = NULL)
Arguments
pathRoute to listen to.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
POST Method
Add routes to listen to.
Method options()
Usage
Routing$options(path, handler, error = NULL)
Arguments
pathRoute to listen to.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
OPTIONS Method
Add routes to listen to.
Method all()
Usage
Routing$all(path, handler, error = NULL)
Arguments
pathRoute to listen to.
handlerFunction that accepts the request and returns an object
describing an httpuv response, e.g.: response().
errorHandler function to run on error.
Details
All Methods
Add routes to listen to for all methods GET, POST, PUT, DELETE, and PATCH.
Method receive()
Usage
Routing$receive(name, handler)
Arguments
nameName of message.
handlerFunction to run when message is received.
Details
Receive Websocket Message
Examples
app <- Ambiorix$new()
app$get("/", function(req, res){
res$send("Using {ambiorix}!")
})
app$receive("hello", function(msg, ws){
print(msg) # print msg received
# send a message back
ws$send("hello", "Hello back! (sent from R)")
})
if(interactive())
app$start()
Method print()
Usage
Routing$print()
Details
Print
Method use()
Usage
Routing$use(use)
Arguments
useEither a router as returned by Router, a function to use as middleware,
or a list of functions.
If a function is passed, it must accept two arguments (the request, and the response):
this function will be executed every time the server receives a request.
Middleware may but does not have to return a response, unlike other methods such as get
Note that multiple routers and middlewares can be used.
Details
Use a router or middleware
Method get_routes()
Usage
Routing$get_routes()
Details
Get the routes
Method get_receivers()
Usage
Routing$get_receivers()
Details
Get the receivers
Method get_middleware()
Usage
Routing$get_middleware()
Details
Get the middleware
Method clone()
The objects of this class are cloneable with this method.
Usage
Routing$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.