Permalink
Browse files

provide raw access to the http server object through a callback passe…

…d to fab.listen. useful for integrating with socket.io
  • Loading branch information...
1 parent 2ddf8e8 commit 54dcf1a371e25fad94fe750625897f782be87055 @technoweenie committed Sep 25, 2010
Showing with 8 additions and 5 deletions.
  1. +8 −5 index.js
View
13 index.js
@@ -44,14 +44,17 @@ fab.import = function( write, obj ) {
return write;
}
-fab.listen = function( write, port ) {
+fab.listen = function( write, port, serverCallback ) {
var url = require( "url" );
return fab.stream( function read( stream ) {
- require( "http" )
- .createServer( listener( stream ) )
- .listen( port );
-
+ var server = require( "http" )
+ .createServer( listener( stream ) );
+ server.listen( port );
+ if ( serverCallback ) {
+ serverCallback( server );
+ }
+
return stream( write );
});

0 comments on commit 54dcf1a

Please sign in to comment.