Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

dual functions for basic & err handling #745

Closed
wants to merge 1 commit into from

2 participants

@printercu
app.use(route, function(err, req, res, next) {
  // ...
}, true)

this handler will be involved both for successful & failed requests. One can save session, for example, here. Or log request ended

@printercu printercu commented on the diff
lib/proto.js
@@ -1,4 +1,3 @@
-

github removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tj
Owner
tj commented

unnecessary API complication IMO

@printercu

as you know, man

@printercu printercu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 7, 2013
  1. @printercu
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/proto.js
View
8 lib/proto.js
@@ -1,4 +1,3 @@
-

github removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
/*!
* Connect - HTTPServer
* Copyright(c) 2010 Sencha Inc.
@@ -59,11 +58,12 @@ var env = process.env.NODE_ENV || 'development';
* @api public
*/
-app.use = function(route, fn){
+app.use = function(route, fn, dual){
// default route to '/'
if ('string' != typeof route) {
fn = route;
route = '/';
+ dual = false;
}
// wrap sub-apps
@@ -87,7 +87,7 @@ app.use = function(route, fn){
// add the middleware
debug('use %s %s', route || '/', fn.name || 'anonymous');
- this.stack.push({ route: route, handle: fn });
+ this.stack.push({ route: route, handle: fn, dual: dual });
return this;
};
@@ -186,7 +186,7 @@ app.handle = function(req, res, out) {
} else {
next(err);
}
- } else if (arity < 4) {
+ } else if (arity < 4 || arity === 4 && layer.dual) {
layer.handle(req, res, next);
} else {
next();
Something went wrong with that request. Please try again.