cripslock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 250da8fe4ed5bfc92e496687fc03e7fe12ab8d5e
parent 76649d10624d3e10e746c36ce272c3fd2558768a
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 22 Jul 2025 18:52:48 +0100

set content type for static files

Diffstat:
Mmain.fnl | 11++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/main.fnl b/main.fnl @@ -82,6 +82,15 @@ ) +(fn content-type-for-path [pathname] + (if + (string.match pathname "%.css$") "text/css" + (string.match pathname "%.gif$") "image/gif" + (string.match pathname "%.html$") "text/html" + (string.match pathname "%.jpeg$") "image/jpeg" + (string.match pathname "%.svg$") "image/svg+xml" + (string.match pathname "%.txt$") "text/plain" + "application/octet-stream")) (fn dispatch [route stream] (let [s { :write #(stream:write_chunk $2) } ] @@ -103,7 +112,7 @@ (stream:write_chunk "" true)) :sendfile (with-open [f (io.open route.pathname :r)] - (server.headers stream { :content-type "application/octet-stream" }) + (server.headers stream { :content-type (content-type-for-path route.pathname) }) (stream:write_body_from_file f)) :search (do