more-route
Introduction
more-route is a routing library. It can run both on the client
as well as on the server.
Its possibly special qualities include:
-
it has a precedence system: given the pattern /foo
and the pattern
/{myvariable}
, the path /foo
will match the pattern /foo
, not
the variable.
-
you mix text and variables in a single segment: /prefix{variable}
Usage
var Router = require('more-router');
var router = new Router();
router.addPattern('a', 'found a');
router.addPattern('a/{v}', 'found a/{v}')
router.resolve('a')
router.resolve('a/foo')
router.consume(['foo', 'a'])
router.resolve('notthere')
Background
more-route is derived from the routing code in the Morepath web
framework written in Python.