Skip to content

Commit

Permalink
Get the rest of the args and pass to handlers
Browse files Browse the repository at this point in the history
This adds support for libraries like [micro-route](https://github.com/dotcypress/micro-route) which pass params/query through to route handlers.
  • Loading branch information
samtgarson authored Feb 15, 2017
1 parent 94f057a commit 3c355c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = exports = function (map) {
const allowed_verbs = Object.keys(map).map(v => v.toUpperCase()).join(', ')

return (req, res) => {
return (req, res, ...args) => {
res.setHeader('Access-Control-Request-Method', allowed_verbs)
const {method} = req
const fn = map[method.toLowerCase()]
Expand All @@ -10,6 +10,6 @@ module.exports = exports = function (map) {
res.end('Method Not Allowed')
return
}
return fn(req, res)
return fn(req, res, ...args)
}
}

0 comments on commit 3c355c2

Please sign in to comment.