/**
 * Middleware to serve public files.
 * @function loader.definePublicFilesMiddleware
 * @param {object} context - Server context object.
 * @param {string} context.PUBLIC_DIR_PATH - Public file directory name.
 * @returns {object} - A public files middleware.
 * @author Taka Okunishi
 *
 */

module.exports = function (context) {
    context.assertKeys(['PUBLIC_DIR_PATH']);
    var connect = require('connect'),
        staticMiddleware = connect.static(context.PUBLIC_DIR_PATH);
    return function (req, res, next) {
        return staticMiddleware(req, res, next);
    }
};