night-route
v0.1.0
Published
fast routing without regexp
Downloads
3
Readme
night-route
fast routing without regexp
using with koa
const { Router } = require('night-route/koa')
let router = new Router()
router.get('/size/:width/:height', ctx => {
ctx.body = ctx.params.width * ctx.params.height
})
app.use(router.routes())
in batch
router.route('/posts', {
get (ctx) {}
post (ctx) {}
})
router.route('/posts/:id', middleware, middleware2, {
get (ctx) {},
put (ctx) {},
delete (ctx) {}
})
shorthands
const { GET } = require('night-route/koa')
app.use(GET('/', ctx => {
ctx.body = "index"
}))
more http methods
router.route('TRACE', ctx => {})