The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

routing

routing is an R port of pillarjs/router, the routing mechanism that underpins Express.js. It gives R web frameworks a syntax that mimics how Express.js applications are written, so the same patterns that make Express.js applications easy to read and reason about are now available in R.

Installation

pak::pak("JulioCollazos64/routing")

Let’s look at an example:

library(routing)
router <- Router$new()
router$use(function(req,res){
  print(req)
})
router$get("/hello", function(req,res){
  res$send("Hello world!")
})

Even if we knew nothing about web development, we can clearly see the things that matter from this code snippet:

Moreover, the routing mechanism happens in the same order you write your code so you can read how your request goes from top to bottom.

How it differs from Express.js

  1. We use forward() instead of next() to pass control to the next handler.
  2. You don’t need to declare forward as an argument to your handler to call it inside.
  3. If your handler doesn’t return a response or call forward(), one is called on your behalf.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.