Skip to content

Commit

Permalink
restrict to only post method
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Nov 25, 2018
1 parent f8400d9 commit 8205891
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ require("@babel/register")
const post = require('./lib/postHandler')
const http = require('http')
const URL = require('url')
const resp = require('./lib/response').default

http.createServer((req, res) => {
if (req.method !== 'POST') {
return resp(res, null)(`Invalid request method: ${req.method}`, 422)
}

const url = URL.parse(req.url, true)
const ctype = req.headers['Content-Type'] | req.headers['content-type']

Expand Down
2 changes: 1 addition & 1 deletion lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default (rsp, callback) => {
}

rsp.writeHead(code, headers || rspHeaders)
rsp.send(body)
rsp.write(body)
rsp.end()
}
}

0 comments on commit 8205891

Please sign in to comment.