本文整理汇总了TypeScript中serve-static.mime类的典型用法代码示例。如果您正苦于以下问题:TypeScript mime类的具体用法?TypeScript mime怎么用?TypeScript mime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mime类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
setHeaders: (response, path) => {
if (ServeStatic.mime.lookup(path) === "text/html") {
// don't cache html
response.setHeader("Cache-Control", "no-cache");
}
else if (/\/(css|javascript)$/.test(ServeStatic.mime.lookup(path))) {
// cache css and javascript for a year as we bust it automatically
response.setHeader("Cache-Control", "public, max-age=31536000");
}
}
示例2: express
import * as express from 'express';
import * as serveStatic from 'serve-static';
var app = express();
app.use(serveStatic('/1'));
app.use(serveStatic('/2', { }));
app.use(serveStatic('/3', {
dotfiles: 'ignore',
etag: true,
extensions: ['html'],
fallthrough: true,
index: true,
lastModified: true,
maxAge: 0,
redirect: true,
setHeaders: function(res: express.Response, path: string, stat: any) {
res.setHeader('Server', 'server-static middleware');
}
}));
serveStatic.mime.define({
'application/babylon': ['babylon'],
'application/babylonmeshdata': ['babylonmeshdata'],
'application/fx': ['fx']
});