diff --git a/lib/middleware/common.js b/lib/middleware/common.js index b13433e64..f7255ffbb 100644 --- a/lib/middleware/common.js +++ b/lib/middleware/common.js @@ -92,9 +92,20 @@ var setHeavyCacheHeaders = function (response) { response.setHeader('Cache-Control', 'public, max-age=31536000') } +var initializeMimeTypes = function (config){ + if(config && config.mime){ + for (var mimeType in config.mime) { + var map = {} + map[mimeType] = config.mime[mimeType] + mime.define(map) + } + } +} + // PUBLIC API exports.PromiseContainer = PromiseContainer exports.createServeFile = createServeFile exports.setNoCacheHeaders = setNoCacheHeaders exports.setHeavyCacheHeaders = setHeavyCacheHeaders +exports.initializeMimeTypes = initializeMimeTypes exports.serve404 = serve404 diff --git a/lib/web-server.js b/lib/web-server.js index fbb9c6eb4..a6ef00e5a 100644 --- a/lib/web-server.js +++ b/lib/web-server.js @@ -31,6 +31,7 @@ createCustomHandler.$inject = ['customFileHandlers', 'config.basePath'] var createWebServer = function (injector, emitter, fileList) { var config = injector.get('config') + common.initializeMimeTypes(config); var serveStaticFile = common.createServeFile(fs, path.normalize(__dirname + '/../static'), config) var serveFile = common.createServeFile(fs, null, config) var filesPromise = new common.PromiseContainer()