Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unmatched routes return default 404.

  • Loading branch information...
commit cbb87d29f2582120b582bf17a4dfc4b3974fe450 1 parent 7a09840
@twentyrogersc authored
Showing with 15 additions and 0 deletions.
  1. +7 −0 index.js
  2. +8 −0 test/teller.js
View
7 index.js
@@ -17,6 +17,13 @@ var routes = {
post: crossroads.create()
}
+var bypassed = function(req, res) {
+ res.show404()
+}
+
+routes.get.bypassed.add(bypassed)
+routes.post.bypassed.add(bypassed)
+
app.settings = function(opts) {
for (var opt in opts) {
View
8 test/teller.js
@@ -67,6 +67,14 @@ describe('app', function() {
done()
})
})
+ it('should return a 404 for an unmatched route', function(done) {
+ request('http://localhost:1234/doesnotexist', function(err, res, body) {
+ res.headers['content-type'].should.equal('text/html')
+ res.statusCode.should.equal(404)
+ body.should.equal('<h1>404, not found</h1>')
+ done()
+ })
+ })
})
describe('post()', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.