router

A simple router that binds URLs paths and patterns to functions.

Stars
9
Committers
1

Router

A simple router utility to match patterns with URLs.

Installation

npm install git+https://[email protected]/philipwalton/router.git

Usage

var router = require('router');

new Router()
    .case('/', function() {
      // The home page.
    });
    .case('/products/', function() {
      // The products list page.
    })
    .case('products/<id>/', function(id) {
      // An individual product page. The `id` variable is passed through.
    })
    .match(location.pathname);

API Reference