var robohydra     = require("robohydra"),
    heads         = robohydra.heads,
    RoboHydraHead = heads.RoboHydraHead;

exports.getBodyParts = function(conf) {
    "use strict";

    var delayMilliseconds = conf.delaymillis || 2000,
        delayPath = conf.delaypath || '/.*';

    conf.robohydra.registerDynamicHead(new RoboHydraHead({
        name: 'delayer',
        path: delayPath,
        handler: function(req, res, next) {
            setTimeout(function() {
                next(req, res);
            }, delayMilliseconds);
        }
    }));

    return {
        heads: [
            new RoboHydraHead({
                name: 'delayer-config',
                path: '/robohydra-admin/delay/:delayValue',
                handler: function(req, res) {
                    delayMilliseconds = parseInt(req.params.delayValue, 10);
                    res.send("Delay is now set to " + delayMilliseconds +
                                 " milliseconds");
                }
            })
        ]
    };
};

var robohydra     = require("robohydra"),
    heads         = robohydra.heads,
    RoboHydraHead = heads.RoboHydraHead;

exports.getBodyParts = function(conf) {
    "use strict";

    var delayMilliseconds = conf.delaymillis || 2000,
        delayPath = conf.delaypath || '/.*',
        delayDisabled = !!conf.delaydisabled;

    conf.robohydra.registerDynamicHead(new RoboHydraHead({
        name: 'delayer',
        path: delayPath,
        handler: function(req, res, next) {
            setTimeout(function() {
                next(req, res);
            }, delayMilliseconds);
        }
    }));

    return {
        heads: [
            new RoboHydraHead({
                name: 'delayer-config',
                detached: delayDisabled,
                path: '/robohydra-admin/delay/:delayValue',
                handler: function(req, res) {
                    delayMilliseconds = parseInt(req.params.delayValue, 10);
                    res.send("Delay is now set to " + delayMilliseconds +
                                 " milliseconds");
                }
            })
        ]
    };
};

Add option to delayer plugin to start disabled
Add option to delayer plugin to start disabled

It's useful to add the delayer plugin to have it available, but
without enabling by default. Thus, add an option to disable it by
default on startup.
