本文整理汇总了TypeScript中express.Response.getHeader方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Response.getHeader方法的具体用法?TypeScript Response.getHeader怎么用?TypeScript Response.getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类express.Response
的用法示例。
在下文中一共展示了Response.getHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Date
res.end = (chunk?: any, encoding?: string | Function): void => {
res.end = end;
res.end(chunk, (encoding as string));
meta.res = {
statusCode: res.statusCode,
responseTime: (new Date() as any) - res.locals.startTime,
};
if (resLog.headers) {
// there are 2 headers that will not appear here:
// 1. Date: "server date"
// 2. Connection: "keep-alive"
// there is an npm package that extracts these 2 headers too but it doesn't make sens to use it just for that
// npm: https://github.com/watson/http-headers
meta.res.headers = (res as any)._headers;
}
if (resLog.body && chunk) {
const contentType = res.getHeader("content-type");
const isJson = typeof contentType === "string" && contentType.indexOf("json") >= 0;
meta.res.body = bodyToString(chunk, isJson);
}
logger.info("http-logger", meta);
};