chore: rename `resp` -> `res`

This commit is contained in:
shiftinv 2022-09-06 04:00:52 +02:00
parent f3bfaf54ec
commit b89fd630f1
1 changed files with 7 additions and 7 deletions

14
main.ts
View File

@ -21,26 +21,26 @@ async function setupLogs(): Promise<void> {
async function handleRequest(req: Request, connInfo: http.ConnInfo): Promise<Response> {
const reqLog = requestLog(req.headers);
let resp: Response;
let res: Response;
try {
resp = await handler(req);
res = await handler(req);
} catch (err) {
if (http.isHttpError(err) && err.expose) {
reqLog.warning(`http error: ${err.message}`);
resp = new Response(err.message, { status: err.status });
res = new Response(err.message, { status: err.status });
} else {
reqLog.critical(err);
resp = new Response("Internal Server Error", { status: 500 });
res = new Response("Internal Server Error", { status: 500 });
}
}
const respLen = resp.headers.get("content-length") || 0;
const respLen = res.headers.get("content-length") || 0;
const addr = connInfo.remoteAddr as Deno.NetAddr;
reqLog.info(
`http: ${addr.hostname}:${addr.port} - ${req.method} ${req.url} ${resp.status} ${respLen}`,
`http: ${addr.hostname}:${addr.port} - ${req.method} ${req.url} ${res.status} ${respLen}`,
);
return resp;
return res;
}
if (import.meta.main) {