koa-param

1.0.2 • Public • Published

koa-param

resolve url params

install

$ npm install koa-param

usage

import koa from 'koa';
import param from 'koa-param';
 
const app = koa();
 
app
  .use(param('/users/:id', resolve))
  .use(show);
 
function* resolve(id, next) {
  this.id = id;
  yield* next;
}
 
function* show() {
  this.body = this.id;
}
 
// > GET /users/123
// < 123

license

MIT

Package Sidebar

Install

npm i koa-param

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • lennon