An open API service indexing awesome lists of open source software.

https://github.com/codemix/dispatching

Tiny routing / dispatch library for node and the browser.
https://github.com/codemix/dispatching

Last synced: 8 months ago
JSON representation

Tiny routing / dispatch library for node and the browser.

Awesome Lists containing this project

README

          

# Dispatching

[![Build Status](https://travis-ci.org/codemix/dispatching.svg)](https://travis-ci.org/codemix/dispatching)

URL routing library for node.js and the browser.

## Installation

```
npm install dispatching
```

## Usage

```js
var dispatcher = new Dispatcher();

dispatcher.add('///', function (params) {
return params;
});

dispatcher.add('//', function (params) {
return params;
});

dispatcher.add('/', function (params) {
return params;
});

dispatcher.dispatch('/users/123/update').should.eql({
controller: 'users',
action: 'update',
id: 123
});

dispatcher.dispatch('/users/123').should.eql({
controller: 'users',
id: 123
});

dispatcher.dispatch('/users').should.eql({
controller: 'users'
});

```

## License

MIT, see [LICENSE.md](./LICENSE.md)