本文整理匯總了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);
};