Started "helpful 404" support
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 14c479f · Browse files · 3 files·+44 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+44 added−4 removed
- tests:+15 added−3 removed
- other:+29 added−1 removed
Provenance
- Commit
6642c4c- Tree
87e3e58- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
14c479f
3 files changed+44 added−4 removed
added:lib/express/pages/not-found.js+28 added
12345678910111213141516171819202122232425262728
// Express - Pages - Not Found - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
var style = require('express/pages/style').style
exports.render = function() { contentType('html') var request = Express.server.request, method = request.method, path = request.uri.path return '<html> \n\ <head> \n\ <title>Express -- Not Found</title> \n\ ' + style + ' \n\ </head> \n\ <body> \n\ <div id="wrapper"> \n\ <h1>Express</h1> \n\ <h2><em>404</em> Not Found</h2> \n\ <ul id="stacktrace"> \n\ ' + method + '(\'' + path + '\', function(){ \n\ // Try this :) \n\ }) \n\ </ul> \n\ </div> \n\ </body> \n\ </html>'}No newline at end of filemodified:lib/express/pages/show-exceptions.js+1 added-1 removed
122345626 unmodified lines
// Express - Show Exceptions - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)// Express - Pages - Show Exceptions - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
var style = require('express/pages/style').style
exports.render = function(e) {26 unmodified linesmodified:spec/spec.routing.js+15 added-3 removed
167 unmodified lines168 end169 end170 171 describe 'with an unmatchable request path'172- it 'should respond with 404 Not Found'173- get('/something').status.should.eql 404174- get('/something').body.should.eql 'Not Found'172+ describe 'with "helpful 404" enabled'173+ it 'should show the help html'174+ enable('helpful 404')175+ get('/something').status.should.eql 500176+ get('/something').body.should.include('<h1>Express</h1>')177+ get('/something').body.should.include('<h2><em>404</em> Not Found</h2>')178+ get('/something').body.should.include("get('/something'")179+ end180 end181+ 182+ describe 'with "helpful 404" disabled'183+ it 'should respond with 404 Not Found'184+ get('/something').status.should.eql 404185+ get('/something').body.should.eql 'Not Found'186+ end187+ end188 end189 190 describe 'with an exception thrown'191 describe 'with "show exceptions" enabled'45 unmodified lines