2.0.1 • Published 8 years ago

ruta3 v2.0.1

Weekly downloads
1,916
License
-
Repository
github
Last release
8 years ago

ruta3

Route matcher devised for shared rendering JavaScript applications

Install

npm install --save ruta3

Sample Usage

Get a router instance

var ruta3 = require('ruta3');
var router = ruta3();

Add some routes

router.addRoute('/articles', getArticles);
router.addRoute('/articles/:slug', getArticleBySlug);
router.addRoute('/articles/search/*', searchForArticles);

Find a match

router.match('/articles');

You'll get null back if no route matches the provided URL. Otherwise, the route match will provide all the useful information you need inside an object.

KeyDescription
actionThe action passed to addRoute as a second argument. Using a function is recommended
nextFall through to the next route, or null if no other routes match
routeThe route passed to addRoute as the first argument
paramsAn object containing the values for named parameters in the route
splatsAn object filled with the values for wildcard parameters

License

MIT

(originally derived from routes, which is no longer maintained)