0.3.0 • Published 9 years ago
@koax/route v0.3.0
route
Simple route middlekoax for koax.
Installation
$ npm install @koax/route
Usage
import koax from 'koax'
import {route, request} from '@koax/route'
let router = koax()
router.use(route('/dep', () => 'norf'))
router.use(route('/foo', function * () {
let res = yield request('/dep')
return 'bar ' + res
}))
router(request('/foo')).then((res) => res) // => 'bar norf'
API
route(path, handler)
Route middleware.
path
- pathhandler
- function to execute on matched path.handler
has signaturehandler(params)
.
Returns: koax middleware
request(path, params)
Request action creator.
path
- path to requestparams
- params to path to handler
Returns: action object
mount(path, middleware)
Mount middleware.
path
- path to mount middleware atmiddleware
- middleware to mount
Returns: koax middleware
License
MIT