add headers_lib

This commit is contained in:
Swrup 2025-09-28 21:27:15 +02:00
parent 72426790b4
commit 4cbf3c722c
6 changed files with 110 additions and 92 deletions

View file

@ -102,12 +102,13 @@ let is_supported_mimetype mime = Array.mem mime supported_mimetype_arr
(* ! lang and mime must be supported *)
let get_content ~lang ~mime t =
let etag = Headers_lib.Etag.to_raw_string (etag t) in
let ext =
match Util.mimetype_to_extension mime with
| None -> Fmt.failwith "mimetype `%s/%s` unknown" (fst mime) (snd mime)
| Some ext -> ext
in
let path = Fpath.to_string Fpath.((base_dir t / lang / etag t) + ext) in
let path = Fpath.to_string Fpath.((base_dir t / lang / etag) + ext) in
match Assets_crunch.read path with
| None -> Fmt.failwith "static file not found: `%s`" path
| Some data -> data