/**
 * Response enhance middleware.
 * @function serverside.middleware.defineResEnhanceMiddleware
 * @param {object} context - Server context object.
 * @param {object} context.responseEnhanceFunctions - Enhance modules. Keys are enhance name, values are functions.
 * @returns {function} - A res enhance middleware.
 * @author Taka Okunishi
 *
 */
var _enhanceObject = require('./_enhance_object');
exports = module.exports = function (context) {
    var enhanceFunctions = context.responseEnhanceFunctions;
    if (!enhanceFunctions) {
        throw new Error('context.responseEnhanceFunctions missing.');
    }
    return function (req, res, next) {
        _enhanceObject(res, enhanceFunctions);
        next();
    };
};
