A very-simple router, inspired by
(You probably want to use
page.js, honestly. This is just me experimenting!)
Include in a
const router = ;
router(path, callback[, callback ...])
Create a route mapping
callback. See Route Callbacks for a description of the signature.
Returns the same
router instance for optional chaining.
/:params as well as
/path/* style wildcards. No regex stuff though.
Begin route matching for a path.
fn will be called when all matched route handlers are complete.
fn that will be called when a route handler cannot be found.
Route callbacks are passed two arguments:
ctx, a shared object available to all handlers of a request
next(), a function that will invoke any further route handlers.