var Flow = require('flow');
var http = require('spdy');
var express = require('express');
var sessions = require('client-sessions');

exports.start = function (options, data, next) {

    // TODO call next, if server is runing
    var instance = this;

    // get global configs
    options.ssl = options.ssl || Flow.config.ssl;
    options.ses_conf = options.ses_conf|| Flow.config.session;

    var app = express();
    Flow.server = http.createServer(options.ssl, app);
    var clientSession = sessions(options.ses_conf);

    // use encrypted client sessions
    app.use(clientSession);

    // emit url to flow
    app.use(function (req, res) {

        var stream = instance.flow('http_req', {
            req: req,
            res: res,
            session: req.session
        });
        stream.o.pipe(res);
        stream.o.on('error', function (err) {
            res.status(err.code || 500).send(err.stack);
        });
        req.pipe(stream.i);

        // since GET requests are ended immediately, write the url manually to the input
        if (req.method === 'GET') {
            stream.i.write(req.url);
        }
    });

    // start http server
    Flow.server.listen(options._.port, function () {
        console.log('flow-http is listening on port', options._.port);
        next();
    });
};

@@ -53,42 +53,8 @@
 ');%0A
-var express = require('express');%0A
 var 
@@ -215,108 +215,41 @@
 is;%0A
-%0A
     
-// get global configs%0A    options.ssl = options.ssl %7C%7C Flow.config.ssl;%0A    options.ses_conf = 
+var clientSession = sessions(
 opti
@@ -286,36 +286,12 @@
 sion
-;%0A%0A    var app = express(
 );%0A
+%0A
     
@@ -337,69 +337,56 @@
 .ssl
-, app);%0A    var clientSession = sessions(options.ses_conf);%0A%0A
+ %7C%7C Flow.config.ssl, function (req, res) %7B%0A%0A    
     
@@ -422,24 +422,20 @@
 ons%0A    
-app.use(
+    
 clientSe
@@ -443,48 +443,19 @@
 sion
-);%0A%0A    // emit url to flow%0A    app.use(
+(req, res, 
 func
@@ -456,37 +456,33 @@
 , function (
-req, res
 ) %7B%0A%0A
+    
         var 
@@ -518,16 +518,20 @@
 req', %7B%0A
+    
         
@@ -556,16 +556,20 @@
         
+    
 res: res
@@ -570,16 +570,20 @@
 s: res,%0A
+    
         
@@ -607,36 +607,44 @@
 session%0A        
+  
+  
 %7D);%0A
+    
         stream.o
@@ -655,16 +655,20 @@
 e(res);%0A
+    
         
@@ -717,16 +717,20 @@
         
+    
 res.stat
@@ -766,32 +766,36 @@
 stack);%0A        
+    
 %7D);%0A        req.
@@ -790,16 +790,20 @@
         
+  
+  
 req.pipe
@@ -811,24 +811,28 @@
 stream.i);%0A%0A
+    
         // s
@@ -908,16 +908,20 @@
 e input%0A
+    
         
@@ -956,24 +956,28 @@
             
+    
 stream.i.wri
@@ -997,17 +997,33 @@
         
-%7D
+    %7D%0A        %7D);
 %0A    %7D);

use standard http server, instead of express