~romuloalves/micro-get

65be5d91809171ab51633c571475f50534dc873a — Rômulo Alves 4 years ago 93cb798
Including Accept Header even when the unaccepted method is called
1 files changed, 1 insertions(+), 1 deletions(-)

M src/index.js
M src/index.js => src/index.js +1 -1
@@ 4,13 4,13 @@ const ALLOWED_HTTP_METHOD = 'GET'

module.exports = exports = function (fn) {
  return (req, res) => {
    res.setHeader('Access-Control-Request-Method', ALLOWED_HTTP_METHOD)
    const {method} = req
    if (method !== ALLOWED_HTTP_METHOD) {
      res.writeHead(405)
      res.end('Method Not Allowed')
      return
    }
    res.setHeader('Access-Control-Request-Method', ALLOWED_HTTP_METHOD)
    return fn(req, res)
  }
}