expose response object within filter callback

This commit is contained in:
Andi Dittrich 2020-11-29 20:17:20 +01:00
parent 402f73502c
commit e7ba75e59e
5 changed files with 9 additions and 4 deletions

View file

@ -4,6 +4,11 @@ CHANGELOG
Branch 3.X.X
------------------------------------------------------
### 3.1.0 ###
* Added: exposed `express.js` response object within `filter()` callback
### 3.0.0 ###
* Refactored the whole codebase

View file

@ -45,7 +45,7 @@ async function bootstrap(){
footer: 'Hello <strong>World</strong>',
pagetitle: 'we are sorry - an internal error encountered',
},
filter: function(data){
filter: function(data, req, res){
// remove footer
//data.footer = null;
return data;

View file

@ -14,7 +14,7 @@ async function bootstrap(){
footer: 'Hello <strong>World</strong>',
pagetitle: 'we are sorry - an internal error encountered',
},
filter: function(data){
filter: function(data, ctx){
// remove footer
//data.footer = null;
return data;

View file

@ -27,7 +27,7 @@ async function createDispatcher(options={}){
// standard http-error-pages
html: function(){
res.type('.html');
res.send(_render(resources.template, resources.stylesheet, opt.filter(templateVars, req)))
res.send(_render(resources.template, resources.stylesheet, opt.filter(templateVars, req, res)))
},
// json

View file

@ -1,6 +1,6 @@
{
"name": "http-error-pages",
"version": "3.0.0",
"version": "3.1.0",
"description": "Simple HTTP Error Pages. standalone + static + koa + express",
"engines": {
"node": ">=7.6"