0.1.1 • Published 11 years ago

match-route v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
11 years ago

match-route

Match a request against a object of routes

installation

component/component

$ component install [--dev] ramitos/match-route

npm

$ npm install [--save/--save-dev] match-route

example

var mr = require('match-route'),
    assert = require('assert');

mr({
  method: 'PUT',
  url: '/user/admin?q1=3&q2=t'
}, {
  'get': {
    '/user/:id/age': 'some string',
    '/': true
  },
  'post': {
    '/user/:id/:age': 45
  },
  'put': {
    '/:type/:subtype': 'other string'
  },
  'delete': {
    '/user/:id': false
  }
}, function (value, route, params, query) {
  assert(route === '/:type/:subtype');
  assert(params.subtype === 'admin');
  assert(value === 'other string');
  assert(params.type === 'user');
  assert(query.q1 === '3');
  assert(query.q2 === 't');
});

license

MIT

0.1.1

11 years ago

0.1.0

11 years ago

0.0.4

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago