Skip to content

Allowing connect to be used as middleware #701

merged 3 commits into from Jan 13, 2013

3 participants


As in #697.

Let me know if you would like a test case as well.

This allows me to write the following code:

  var connect = require('connect'),
    http = require('http');

var myHandler = my_async_handler_generator();
var connectHandler = connect();

myHandler.on(function(req, res, next) {
  console.log('This handler comes before anything else');


myHandler.on(function(req, res, next) {
  res.writeHead(200, {
    'Content-Type': 'text/plain'
  res.end('This is the next fall through after the connect handlers');

Sencha Labs member
tj commented Dec 6, 2012

test case would be good thanks


I've added in a test case for this. I've included it in server.js, but it may make more sense as a separate file.


It seems that the Travis build test doesn't like the following:

  http.get('http://localhost:5556/', function(res){

The test was working fine on my localhost, suggestions on getting this working welcome.


Failing in node.js 0.6.21, per .

This is because node's interface of http.get() changed from 0.6 to 0.8, per

See also:

Try replacing that line with:

        host: 'localhost',
        port: 5556,
        path: '/'
      }, function(res){

Thanks very much for the suggestion - I've added this in.


Just checking if this needs any further discussion or changes?

@tj tj merged commit 6ed44ac into senchalabs:master Jan 13, 2013

1 check passed

Details default The Travis build passed

Sweet, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.