Nice little Trie-based HTTP router
Built with ❤︎ by tiaanduplessis and contributors
Built on top of routington. If your looking for something fast, try find-my-way instead.
$ npm install @tiaanduplessis/routify
# OR
$ yarn add @tiaanduplessis/routify
const routify = require('@tiaanduplessis/routify')
const http = require('http')
const app = routify()
app.use(({ req }, next) => {
console.log(`Request to ${req.url}`)
next()
})
app.route({
url: '/',
method: 'GET',
handler: (ctx, next) => {
ctx.res.end('Hai')
}
})
app.route({
url: '/foo',
method: 'GET',
handler: (ctx, next) => {
ctx.res.end('foo!')
}
})
http.createServer(app.lookUp).listen(8888)
Contributions are welcome!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
Licensed under the MIT License.