Skip to content
/ ruta3 Public

Route matcher devised for shared rendering JavaScript applications

License

Notifications You must be signed in to change notification settings

bevacqua/ruta3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Key Description
action The action passed to addRoute as a second argument. Using a function is recommended
next Fall through to the next route, or null if no other routes match
route The route passed to addRoute as the first argument
params An object containing the values for named parameters in the route
splats An object filled with the values for wildcard parameters

License

MIT

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

About

Route matcher devised for shared rendering JavaScript applications

Resources

License

Stars

Watchers

Forks

Packages

No packages published