~romuloalves/micro-get

93cb7980a5b48cbcd1e16fe3852c984358ee3d0f — Rômulo Alves 4 years ago b0ccbb5
Changing HTTP code to 405
2 files changed, 3 insertions(+), 3 deletions(-)

M README.md
M src/index.js
M README.md => README.md +1 -1
@@ 21,7 21,7 @@ const get = require('micro-get')

/*
  - GET requests will execute the function
  - Non-GET requests will return HTTP Code 404
  - Non-GET requests will return HTTP Code 405
*/
module.exports = get(async (req, res) => {
  return send(res, 200, `It's a GET request!`)

M src/index.js => src/index.js +2 -2
@@ 6,8 6,8 @@ module.exports = exports = function (fn) {
  return (req, res) => {
    const {method} = req
    if (method !== ALLOWED_HTTP_METHOD) {
      res.writeHead(404)
      res.end('Not Found.')
      res.writeHead(405)
      res.end('Method Not Allowed')
      return
    }
    res.setHeader('Access-Control-Request-Method', ALLOWED_HTTP_METHOD)