Created
December 7, 2018 14:14
-
-
Save evanxg852000/e67b07090385525ae247a4206faa8c02 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_handleRequest(request, response){ | |
// typeof(response.render) -> undefined | |
this._patchResponse(response) | |
// typeof(response.render) -> function | |
this.router._dispatch(request, response) | |
} | |
_patchResponse(response){ | |
response.render = (file, context) => { | |
try { | |
// The only place we access the template engine | |
response.end(this.templater.render(file, context)) | |
} catch (err) { | |
// Nobody shows stacktrace to users in production right? | |
if(this.config.env.toLowerCase().startsWith('prod')){ | |
response.statusCode = 500; | |
response.end('Internal Server Error') | |
return | |
} | |
response.end(`${err.message} \n ${err.stack}`) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment