Skip to content

Commit

Permalink
Add catchall route
Browse files Browse the repository at this point in the history
  • Loading branch information
jotaen committed May 1, 2016
1 parent 69c0780 commit bce1ac9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/http/app.js
Expand Up @@ -131,3 +131,7 @@ router.delete(
})
}
)

router.all('*', (req, res) => {
handle.methodNotAllowed(res, 'GET, POST, PUT, DELETE')
})
13 changes: 13 additions & 0 deletions test/http/errorsTest.js
Expand Up @@ -73,4 +73,17 @@ describe('errors', () => {
else validate.error(res.body).then(done)
})
})

it('should refuse unkown methods, such as PATCH', (done) => {
request(app)
.patch('/lalala')
.auth(config.username, config.password)
.expect(405)
.expect('Allow', 'GET, POST, PUT, DELETE')
.expect('Content-Type', /json/)
.end((err, res) => {
if (err) done(err)
else validate.error(res.body).then(done)
})
})
})

0 comments on commit bce1ac9

Please sign in to comment.