/*globals module, require*/

var stack = require('stack'),
    http = require('http'),
    _hs = http.createServer;

http.createServer = function createServer () {
    'use strict';
    return _hs.call(http,
        stack.apply(stack, Array.prototype.slice.call(arguments))
    );
};

http.createMiddlewareServer = function (mws) {
    'use strict';
    mws = Array.prototype.slice.call(arguments);
    return function () {
        return _hs.call(http,
            stack.apply(stack, mws.concat(Array.prototype.slice.call(arguments)))
        );
    };
};

module.exports = http;

/*globals module, require*/

var stack = require('stack'),
    http = require('http'),
    _hs = http.createServer;

http.createServer = function createServer () {
    'use strict';
    return _hs.call(http,
        stack.apply(stack, Array.prototype.slice.call(arguments))
    );
};

http.createMiddlewareServer = function (mws) {
    'use strict';
    mws = Array.prototype.slice.call(arguments).reduce(function (arr, arg) {
        return arr.concat(arg); // We only need a single depth, so this is sufficient
    }, []);
    return function createServer () {
        return _hs.call(http,
            stack.apply(stack, mws.concat(Array.prototype.slice.call(arguments))) // We really just need to support one argument for createServer()
        );
    };
};

module.exports = http;

Support one-level nesting of arrays to createMiddlewareServer
Support one-level nesting of arrays to createMiddlewareServer
