1.0.1 • Published 9 years ago
leads-router v1.0.1
leads-router
A minimal routing library of leads.js.
var router = leads.Router();
router.get('/', function(req, res, next) {
res.send('Hello world');
});
router.dispatch('/', 'get'); // or router.get('/');
Description
It has been reduced unnecessary function from leads.js.
If you suffice leads-router, you should use it.
The usage is almost the same as leads.js. However, you can not use part of methods of leads.js.
Installation
$ npm install leads-router # for browserify
$ git clone https://github.com/webkatu/leads-router
<script src="leadsRouter.js"></script>
API
See the leads API.
The following are the available properties and methods in leads-router.
leads
next
Request
- req.app
- req.baseUrl
- req.data
- req.dispatcher
- req.hash
- req.host
- req.hostname
- req.href
- req.method
- req.origin
- req.originalUrl
- req.params
- req.path
- req.pathname
- req.port
- req.protocol
- req.query
- req.search
- req.secure
Router
- router.defaults
- router.all()
- router.all()
- router.dispatch()
- router.METHOD()
- router.METHOD()
- router.param()
- router.route()
- router.use()
Support IE10+
If you support IE10+, you should import WeakMap polyfill before you import leadsRouter.js.
$ npm install weakmap
<script src="weakmap.js"></script>
<script src="leadsRouter.js"></script>
Author
- Twitter @vinyufi
- Blog webkatu.com