all repos — homestead @ 2c6cc1897c9f218e29b8e1f27a67ddbf22f63053

Code for my website

Merge redirect information into standard log line

Alan Pearce
commit

2c6cc1897c9f218e29b8e1f27a67ddbf22f63053

parent

87f03202d8eba167f4b93caa1cd30c0313240685

1 file changed, 4 insertions(+), 3 deletions(-)

jump to
M src/app.tssrc/app.ts
@@ -129,6 +129,7 @@ const url = new URL(request.url);
const pathname = url.pathname.replace(/\/\/+/g, "/"); const endTimer = metrics.requestDuration.startTimer({ path: pathname }); let status; + let newpath; const transaction = Sentry.startTransaction({ name: pathname, op: "http.server",
@@ -203,7 +204,7 @@ "content-type": file.type,
}); } else { if (files.has(pathname + "/")) { - log.info(`Redirecting to: ${pathname + "/"}`); + newpath = pathname + "/"; metrics.requests.inc({ method: request.method, path: pathname,
@@ -211,7 +212,7 @@ status_code: (status = 302),
}); return new Response("", { status: status, - headers: { location: pathname + "/" }, + headers: { location: newpath }, }); } metrics.requests.inc({
@@ -249,7 +250,7 @@ } finally {
const seconds = endTimer(); metrics.requestDuration.observe(seconds); transaction.finish(); - console.log(request.method, status, pathname); + console.log(request.method, status, pathname, newpath ? newpath : ""); } }, } satisfies Serve;