Pārlūkot izejas kodu

expose response object within filter callback

Andi Dittrich 4 gadi atpakaļ
vecāks
revīzija
e7ba75e59e
5 mainītis faili ar 9 papildinājumiem un 4 dzēšanām
  1. 5 0
      CHANGES.md
  2. 1 1
      examples/express.js
  3. 1 1
      examples/koa.js
  4. 1 1
      lib/express.js
  5. 1 1
      package.json

+ 5 - 0
CHANGES.md

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

+ 1 - 1
examples/express.js

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

+ 1 - 1
examples/koa.js

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

+ 1 - 1
lib/express.js

@@ -27,7 +27,7 @@ async function createDispatcher(options={}){
             // standard http-error-pages
             // standard http-error-pages
             html: function(){
             html: function(){
                 res.type('.html');
                 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
             // json

+ 1 - 1
package.json

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