test/fixtures/servers/_servers.js
/**
 * Wrapper for HTTP server that emit events with the name of request url path.
 *
 * @example
 * var s = createHTTPServer();
 * s.on('/foo', function (req, res)) {
 *     res.writeHead(200, {'content-type': 'text/plain'});
 *     res.end('Hello world!');
 * }
 * s.listen(3000, callback);
 */
Wrapper for HTTP server that emit events with the name of request url path.
Wrapper for HTTP server that emit events with the name of request url path .
function createHTTPServer () {
    var server = http.createServer(function (req, res) {
        server.emit(req.url.replace(/(\?.*)/, ''), req, res);
    });
    server.on('listening', function () {
        server.port = this.address().port;
        server.url = 'http://localhost:' + server.port;
    });
    enableServerDestroy(server);
    return server;
}
function createHTTPServer ( ) { var server = http . createServer ( function ( req , res ) { server . emit ( req . url . replace ( / (\?.*) / , '' ) , req , res ) ; } ) ; server . on ( 'listening' , function ( ) { server . port = this . address ( ) . port ; server . url = 'http://localhost:' + server . port ; } ) ; enableServerDestroy ( server ) ; return server ; }
Wrapper for HTTP server that emit events with the name of request url path.
Wrapper for HTTP server that emit events with the name of request url path .