expressjs / expressjs/express

Support for auto-generated Accept-Patch header

Open
#2,878 13 comments 0 reactions 0 assignees View on GitHub
discuss investigate module:router
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

The auto-generated `OPTIONS` response works well, but it there currently isn't any option that you can set to include [Accept-Patch](http://tools.ietf.org/html/rfc5789#section-3.1) for the media type(s) that your API's `PATCH` request accepts.

Creating a middleware function like this doesn't work because the middleware executes before the auto-generated `OPTIONS` response:

``` javascript
let acceptPatch = function(req, res, next) {
if (/PATCH/.test(req.get('Allow')))
res.set('Accept-Patch', 'application/json')
next()
}
router.use(acceptPatch) // won't work because req.get('Allow') hasn't been auto-generated yet
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.