Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/qard/koa-method-match

Method match router for koa, does not handle path matching
https://github.com/qard/koa-method-match

Last synced: about 1 month ago
JSON representation

Method match router for koa, does not handle path matching

Awesome Lists containing this project

README

        

# koa-method-match

Method match router for koa, does not handle path matching. It is intended to be
used with [koa-path](https://www.npmjs.org/package/koa-path), but is not tied to it.

## Usage

```js
var method = require('koa-method-match')
var path = require('koa-path')()

// You can simply pass the method in as a string
app.use(method('get', path('/user/:id', handler)))

// Or you can use method types as functions
var post = method.post
var get = method.get

app.use(post(path('/user', handler)))
app.use(get(path('/user/:id', handler)))
```