rm config.ml
This commit is contained in:
parent
bfc68deb34
commit
8ad3df8f54
6 changed files with 71 additions and 66 deletions
37
src/util.ml
37
src/util.ml
|
|
@ -1,43 +1,8 @@
|
|||
(* TODO *)
|
||||
module Protocol_version = struct
|
||||
(* libtool version format *)
|
||||
(* todo *)
|
||||
let current = 0
|
||||
let revision = 0
|
||||
let age = 0
|
||||
let v = Fmt.str "%d:%d:%d"
|
||||
end
|
||||
|
||||
module Mimetype = struct
|
||||
let mimetype_extension_assoc =
|
||||
[
|
||||
(("text", "plain"), ".txt"); (("text", "markdown"), ".md");
|
||||
(("text", "html"), ".html"); (("text", "html"), ".htm");
|
||||
(("application", "pdf"), ".pdf"); (("image", "jpeg"), ".jpg");
|
||||
(("image", "jpeg"), ".jpeg"); (("image", "png"), ".png");
|
||||
(("image", "gif"), ".gif");
|
||||
]
|
||||
|
||||
let mimetype_l, _ = List.split mimetype_extension_assoc
|
||||
|
||||
let of_cohttp_media = function
|
||||
| Cohttp.Accept.MediaType (m, m_sub) ->
|
||||
List.find_opt (( = ) (m, m_sub)) mimetype_l
|
||||
| AnyMediaSubtype m ->
|
||||
List.find_opt (fun (m', _) -> String.equal m m') mimetype_l
|
||||
| AnyMedia -> Some Config.default_mimetype
|
||||
|
||||
let to_extension (m, m_sub) =
|
||||
assert (m <> "*");
|
||||
assert (m_sub <> "*");
|
||||
List.assoc_opt (m, m_sub) mimetype_extension_assoc
|
||||
|
||||
let of_extension ext =
|
||||
List.find_map
|
||||
(fun (mime, ext') ->
|
||||
match String.equal ext ext' with false -> None | true -> Some mime)
|
||||
mimetype_extension_assoc
|
||||
end
|
||||
|
||||
(* -- pretty printers -- *)
|
||||
let pp_mime fmt mime = Fmt.pf fmt "%s/%s" (fst mime) (snd mime)
|
||||
let pp_array pp_item item = Fmt.array ~sep:(Fmt.any ", ") pp_item item
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue