Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (44 sloc) 1.55 KB

Rou Build Status

Url-based router for Node.js and browsers.

Getting Started

###In the Node.js### You can install using Node Package Manager (npm):

npm install rou

###In the Browsers###

<script type="text/javascript" src="rou.min.js"></script>

Also RequireJS module format supported.


var router = Rou();

        .method('get') // method should be 'get'
        .param('new', true) // param 'new' should be
        .param('category', false) // param 'category' shouldn't be
        .param('bounds') // param 'bounds' should be non-empty
        .param('geometry', 'polyline') // param 'bounds' should be 'polyline'
        .param('type', ['road', 'railway']) // param 'type' should be 'road' or 'railway'
        .param('oid', /^\d+$/) // param 'oid' should be integer
        .then(function(req) { // controller action
            // req.query.oid, req.query.sid now available
            // controller action
        .then('/objects', { new : 1 }) // rewrite /objects/new to /objects/?new=1
        .param('type', ['road', 'railway'])
        .then('/objects') // rewrite /objects/road or /objects/railway to /objects/?type=road or /objects/?type=railway
    .otherwise(function() {
    method : 'get',
    path   : '/objects/road',    
    query  : { new : '1' }