Skip to content

Commit

Permalink
refactor: Don't try to support the CONNECT method
Browse files Browse the repository at this point in the history
CONNECT requests must be handled differently so it can't be supported in the same way as the other HTTP methods.
  • Loading branch information
nwoltman committed Jun 16, 2019
1 parent 87df926 commit 7c4ed3c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/Routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app.route(options)

### Options

+ `method`: The name of an HTTP method or an array of methods. Can be any method found in the [`http.METHODS`](https://nodejs.org/api/http.html#http_http_methods) array.
+ `method`: The name of an HTTP method or an array of methods. Can be any method found in the [`http.METHODS`](https://nodejs.org/api/http.html#http_http_methods) array (except for `CONNECT`).
+ `path`: The path to match the URL of the request.
+ `responseSchema`: The schema for a JSON response. See the [`Serialization` documentation](Serialization.md).
+ `preHandler(req, res, next)`: Route-level [`preHandler` hooks](Hooks.md#prehandler). Can be a function or an array of functions. Similar to route-level middleware in Express.
Expand Down
2 changes: 1 addition & 1 deletion lib/RequestHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const methodHandlers = {
}

for (const method of http.METHODS) {
if (!methodHandlers[method]) {
if (!methodHandlers[method] && method !== 'CONNECT') {
methodHandlers[method] = runPreHandlerHooks
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/http-methods/all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const t = require('tap')
const test = t.test
const medley = require('../..')

const supportedMethods = require('http').METHODS
const supportedMethods = require('http').METHODS.filter(method => method !== 'CONNECT')

test('app.all should add all the methods to the same URL', (t) => {
t.plan(supportedMethods.length * 2)
Expand Down

0 comments on commit 7c4ed3c

Please sign in to comment.