src/routers/BindingsDocs/BindingsDocs.js
function initialize(middlewareOpts) {
    const logger = middlewareOpts.logger.fork('BindingsDocs'),
        ensureAuthenticated = middlewareOpts.ensureAuthenticated;

    function servePythonDocFile(rootDir, fileName, res, logger) {
        const options = {
            root: rootDir,
            dotfiles: 'deny',
            headers: {
                'x-timestamp': Date.now(),
                'x-sent': true
            }
        };

        res.sendFile(fileName, options, function (err) {
            if (err) {
                logger.error('Failed to send ' + fileName, err);
                res.status(err.status).end();
            }
        });
    }

    // Ensure authenticated can be used only after this rule.
    router.use('*', function (req, res, next) {
        res.setHeader('X-WebGME-Media-Type', 'webgme.v1');
        next();
    });

    // Use ensureAuthenticated if the routes require authentication. (Can be set explicitly for each route.)
    router.use('*', ensureAuthenticated);

    function getFullUrl(req, name) {
        return req.protocol + '://' + req.headers.host + middlewareOpts.getMountedPath(req) + req.baseUrl + name;
    }

    router.get('/', function (req, res) {
        res.json({
            python: getFullUrl(req, '/python/index.html')
        });
    });

    router.get('/python/', function (req, res) {
        servePythonDocFile(PYTHON_DOCS_DIR, 'index.html', res, logger);
    });

    router.get('/python/*', function (req, res) {
        servePythonDocFile(PYTHON_DOCS_DIR, req.params[0], res, logger);
    });
}
function initialize(middlewareOpts) {
    const logger = middlewareOpts.logger.fork('BindingsDocs'),
        ensureAuthenticated = middlewareOpts.ensureAuthenticated;

    function servePythonDocFile(rootDir, fileName, res, logger) {
        const options = {
            root: rootDir,
            dotfiles: 'deny',
            headers: {
                'x-timestamp': Date.now(),
                'x-sent': true
            }
        };

        res.sendFile(fileName, options, function (err) {
            if (err) {
                logger.error('Failed to send ' + fileName, err);
                res.status(err.status).end();
            }
        });
    }

    // Ensure authenticated can be used only after this rule.
    router.use('*', function (req, res, next) {
        res.setHeader('X-WebGME-Media-Type', 'webgme.v1');
        next();
    });

    // Use ensureAuthenticated if the routes require authentication. (Can be set explicitly for each route.)
    router.use('*', ensureAuthenticated);

    function getFullUrl(req, name) {
        return req.protocol + '://' + req.headers.host + middlewareOpts.getMountedPath(req) + req.baseUrl + name;
    }

    router.get('/', function (req, res) {
        res.json({
            python: getFullUrl(req, '/python/index.html')
        });
    });

    router.get('/python/', function (req, res) {
        servePythonDocFile(PYTHON_DOCS_DIR, 'index.html', res, logger);
    });

    router.get('/python/*', function (req, res) {
        servePythonDocFile(PYTHON_DOCS_DIR, req.params[0], res, logger);
    });
}
Called when the server is created but before it starts to listening to incoming requests.
N.B. gmeAuth, safeStorage and workerManager are not ready to use until the start function is called.
(However inside an incoming request they are all ensured to have been initialized.)

@param {object} middlewareOpts - Passed by the webgme server.
@param {GmeConfig} middlewareOpts.gmeConfig - GME config parameters.
@param {GmeLogger} middlewareOpts.logger - logger
@param {function} middlewareOpts.ensureAuthenticated - Ensures the user is authenticated.
@param {function} middlewareOpts.getUserId - If authenticated retrieves the userId from the request.
@param {object} middlewareOpts.gmeAuth - Authorization module.
@param {object} middlewareOpts.safeStorage - Accesses the storage and emits events (PROJECT_CREATED, COMMIT..).
@param {object} middlewareOpts.workerManager - Spawns and keeps track of "worker" sub-processes.