本文整理匯總了TypeScript中send類的典型用法代碼示例。如果您正苦於以下問題:TypeScript send類的具體用法?TypeScript send怎麽用?TypeScript send使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了send類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: send
(error: send.SendError) => {
if ((error).status === 404 && !filePathRegex.test(filePath)) {
send(req, '/', {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
示例2: send
.on('error', (error: send.SendError) => {
if ((error).status == 404 && !filePath.endsWith('.html')) {
send(req, '/', {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
示例3: send
.on('error', (error: send.SendError) => {
if ((error).status == 404) {
send(req, '/', {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
示例4: send
(error: send.SendError) => {
if ((error).status === 404 && !filePathRegex.test(filePath)) {
// The static file handling middleware failed to find a file on
// disk. Serve the entry point HTML file instead of a 404.
send(req, entrypoint, {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
示例5: pushResources
app.get('/*', (req, res) => {
pushResources(options, req, res);
const filePath = req.path;
send(req, filePath, {root: root})
.on('error',
(error: send.SendError) => {
if ((error).status === 404 && !filePathRegex.test(filePath)) {
send(req, '/', {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
.pipe(res);
});
示例6: pushResources
app.get('/*', (req, res) => {
pushResources(options, req, res);
const filePath = req.path;
send(req, filePath, {root: root, index: entrypoint})
.on('error',
(error: send.SendError) => {
if ((error).status === 404 && !filePathRegex.test(filePath)) {
// The static file handling middleware failed to find a file on
// disk. Serve the entry point HTML file instead of a 404.
send(req, entrypoint, {root: root}).pipe(res);
} else {
res.statusCode = error.status || 500;
res.end(error.message);
}
})
.pipe(res);
});
示例7: send
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 + '/');
res.end('Redirecting to ' + req.url + '/');
})
.on('headers', (res: any, path: string, stat: any) => {
res.setHeader('Content-Disposition', 'attachment');
})
.pipe(res);
});