Permalink
Browse files

Add generator support to the middleware stack

  • Loading branch information...
kenrick committed Jan 19, 2015
1 parent 40f7a8e commit 8dac72bc9b11a71ed52a54bf35768d2ead912238
Showing with 10 additions and 4 deletions.
  1. +5 −0 lib/router/layer.js
  2. +5 −4 package.json
View
@@ -4,6 +4,7 @@
var pathRegexp = require('path-to-regexp');
var debug = require('debug')('express:router:layer');
var co = require('co');
/**
* Module variables.
@@ -73,6 +74,10 @@ Layer.prototype.handle_error = function handle_error(error, req, res, next) {
Layer.prototype.handle_request = function handle(req, res, next) {
var fn = this.handle;
if(fn.constructor.name === 'GeneratorFunction') {
fn = co.wrap(fn);
}
if (fn.length > 3) {
// not a standard request handler
return next();
View
@@ -28,7 +28,9 @@
],
"dependencies": {
"accepts": "~1.2.2",
"co": "^4.1.0",
"content-disposition": "0.5.0",
"cookie": "0.1.2",
"cookie-signature": "1.0.5",
"debug": "~2.1.1",
"depd": "~1.0.0",
@@ -37,6 +39,7 @@
"finalhandler": "0.3.3",
"fresh": "0.2.4",
"media-typer": "0.3.0",
"merge-descriptors": "0.0.2",
"methods": "~1.1.1",
"on-finished": "~2.2.0",
"parseurl": "~1.3.0",
@@ -47,10 +50,8 @@
"send": "0.11.0",
"serve-static": "~1.8.0",
"type-is": "~1.5.5",
"vary": "~1.0.0",
"cookie": "0.1.2",
"merge-descriptors": "0.0.2",
"utils-merge": "1.0.0"
"utils-merge": "1.0.0",
"vary": "~1.0.0"
},
"devDependencies": {
"after": "0.8.1",

1 comment on commit 8dac72b

@Fonger

This comment has been minimized.

Show comment
Hide comment
@Fonger

Fonger Apr 4, 2016

You don't catch the error here. If there's an error in the generator function, it will disappear and end up timeout.

Fonger commented on 8dac72b Apr 4, 2016

You don't catch the error here. If there's an error in the generator function, it will disappear and end up timeout.

Please sign in to comment.