本文整理汇总了TypeScript中send.mime类的典型用法代码示例。如果您正苦于以下问题:TypeScript mime类的具体用法?TypeScript mime怎么用?TypeScript mime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mime类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
export default function() {
const serveStatic = require("serve-static");
/**
* Adding a custom mime-type for wasm whilst we wait for
* the `send` package to be updated.
*/
const send = require("send");
send.mime.define({ "application/wasm": ["wasm"] });
return serveStatic;
}
示例2: express
/// <reference path="send.d.ts" />
/// <reference path="../express/express.d.ts" />
import * as express from 'express';
import * as send from 'send';
var app = express();
send.mime.default_type = 'text/plain';
send.mime.define({
'application/x-my-type': ['x-mt', 'x-mtt']
});
app.get('/test.html', (req, res) => {
send(req, '/test.html', {
maxAge: 0,
root: __dirname + '/wwwroot'
}).pipe(res);
});
app.get('/test.html', (req, res) => {
send(req, '/test.html')
.maxage(0)
.root(__dirname + '/wwwroot')
.on('error', (err: any) => {
res.statusCode = err.status || 500;
res.end(err.message);
})
.on('directory', () => {
res.statusCode = 301;
res.setHeader('Location', req.url + '/');