This commit is contained in:
swrup 2025-11-11 02:32:45 +01:00
parent aa2ff7b2f0
commit 27ce25eded
4 changed files with 27 additions and 18 deletions

View file

@ -1,4 +1,4 @@
version=0.27.0 version=0.28.1
exp-grouping=preserve exp-grouping=preserve
type-decl=sparse type-decl=sparse
break-infix=fit-or-vertical break-infix=fit-or-vertical

View file

@ -28,5 +28,14 @@
jsont jsont
cohttp cohttp
fmt fmt
bin
angstrom
zarith
mirage-crypto
digestif
duration
jsont
cohttp
ptime
(ocamlformat :with-dev-setup) (ocamlformat :with-dev-setup)
)) ))

View file

@ -87,12 +87,12 @@ let supported_lang_arr, supported_ext_arr =
let lang_l = let lang_l =
path_l path_l
|> List.map (fun path -> |> List.map (fun path ->
match Fpath.segs path with match Fpath.segs path with
| [] -> assert false | [] -> assert false
| [ dir; _file ] -> dir | [ dir; _file ] -> dir
| _l -> | _l ->
Fmt.failwith "invalid folder structure, file `%s` is misplaced" Fmt.failwith "invalid folder structure, file `%s` is misplaced"
(Fpath.to_string path)) (Fpath.to_string path))
|> List.sort_uniq String.compare |> List.sort_uniq String.compare
in in
let () = let () =

View file

@ -25,12 +25,12 @@ let select_language headers =
|> Cohttp.Accept.qsort |> Cohttp.Accept.qsort
|> List.map (fun (_q, lang) -> lang) |> List.map (fun (_q, lang) -> lang)
|> List.map (function |> List.map (function
| Cohttp.Accept.AnyLanguage -> Assets.default_lang | Cohttp.Accept.AnyLanguage -> Assets.default_lang
| Language language_range -> ( | Language language_range -> (
(* ignore language subtags (e.g. "en-US" -> "en") *) (* ignore language subtags (e.g. "en-US" -> "en") *)
match language_range with match language_range with
| [] -> assert false | [] -> assert false
| primary_tag :: _ -> primary_tag)) | primary_tag :: _ -> primary_tag))
|> List.find_opt Assets.is_supported_lang |> List.find_opt Assets.is_supported_lang
|> Option.value ~default:Assets.default_lang |> Option.value ~default:Assets.default_lang
@ -40,11 +40,11 @@ let select_encoding headers =
|> Cohttp.Accept.qsort |> Cohttp.Accept.qsort
|> List.map snd |> List.map snd
|> List.filter_map (function |> List.filter_map (function
| Cohttp.Accept.Identity -> Some `Identity | Cohttp.Accept.Identity -> Some `Identity
| Deflate -> Some `DEFLATE | Deflate -> Some `DEFLATE
| Gzip -> Some `Gzip | Gzip -> Some `Gzip
| AnyEncoding -> Some Assets.default_encoding | AnyEncoding -> Some Assets.default_encoding
| Encoding _ | Compress -> (* unsupported *) None) | Encoding _ | Compress -> (* unsupported *) None)
|> function |> function
| [] -> assert false | [] -> assert false
| `Identity :: _ -> None | `Identity :: _ -> None