all repos — homestead @ 963558196ec0f9d337923e2ebda7aad9740d209e

Code for my website

Override content-type for /feed-styles/

Alan Pearce
commit

963558196ec0f9d337923e2ebda7aad9740d209e

parent

8f5fe3d945bec7aeb492e9ef59f9791b1a469dab

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

jump to
M src/index.tssrc/index.ts
@@ -24,6 +24,7 @@ filename: string;
handle: BunFile; relPath: string; headers?: Record<string, string>; + type: string; size: number; mtime: Date; };
@@ -67,10 +68,12 @@
if (files.get(pathname) !== undefined) { console.warn("File already registered:", pathname); } + const handle = Bun.file(filename); files.set(pathname, { filename, relPath: "/" + path, - handle: Bun.file(filename), + handle: handle, + type: pathname.startsWith("/feed-styles") ? "text/xsl" : handle.type, headers: pathname === "/404.html" ? Object.assign({}, defaultHeaders, { "cache-control": "no-cache" })
@@ -185,7 +188,7 @@ span.setTag("http.encoding", "br");
span.setTag("http.status_code", 200); return serveFile(files.get(file.relPath + ".br"), 200, { "content-encoding": "br", - "content-type": file.handle.type, + "content-type": file.type, }); } else if ( encodings.includes("zstd") &&
@@ -195,7 +198,7 @@ span.setTag("http.encoding", "zstd");
span.setTag("http.status_code", 200); return serveFile(files.get(file.relPath + ".zst"), 200, { "content-encoding": "zstd", - "content-type": file.handle.type, + "content-type": file.type, }); } else if ( encodings.includes("gzip") &&
@@ -205,7 +208,7 @@ span.setTag("http.encoding", "gzip");
span.setTag("http.status_code", 200); return serveFile(files.get(file.relPath + ".gz"), 200, { "content-encoding": "gzip", - "content-type": file.handle.type, + "content-type": file.type, }); } span.setTag("http.encoding", "identity");