-> hardcode config
This commit is contained in:
parent
a99eefc9e5
commit
592ebee9a3
4 changed files with 108 additions and 30 deletions
|
|
@ -8,24 +8,15 @@
|
|||
https://docs.taler.net/design-documents/003-tos-rendering.html *)
|
||||
|
||||
(* hardcoded config just for static assets *)
|
||||
module Config = struct
|
||||
let default_lang = "en"
|
||||
let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity
|
||||
let default_lang = "en"
|
||||
let default_encoding : [< `Identity | `DEFLATE | `Gzip ] = `Identity
|
||||
|
||||
(* TODO Taler documentation markdown mimetype should be the prefered one, and be
|
||||
(* TODO Taler documentation markdown mimetype should be the prefered one, and be
|
||||
supported, according to DD we take text/plain as default instead for now *)
|
||||
let default_mimetype = ("text", "plain")
|
||||
let default_extension = ".txt"
|
||||
let terms_dir = Fpath.(v "terms")
|
||||
let privacy_dir = Fpath.(v "privacy")
|
||||
|
||||
(* ETAG is used as base filename it should be encoded in Crockford base-32 we do
|
||||
not generate it and we do not verify it *)
|
||||
let terms_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
||||
let privacy_etag = "0" |> Headers_lib.Etag.of_crockford32 |> Result.get_ok
|
||||
let terms_legal_version = "1"
|
||||
let privacy_legal_version = "1"
|
||||
end
|
||||
let default_mimetype = ("text", "plain")
|
||||
let default_extension = ".txt"
|
||||
let terms_legal_version = "1"
|
||||
let privacy_legal_version = "1"
|
||||
|
||||
module Mimetype = struct
|
||||
let mimetype_extension_assoc =
|
||||
|
|
@ -44,7 +35,7 @@ module Mimetype = struct
|
|||
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
|
||||
| AnyMedia -> Some default_mimetype
|
||||
|
||||
let to_extension (m, m_sub) =
|
||||
assert (m <> "*");
|
||||
|
|
@ -65,16 +56,16 @@ type t =
|
|||
| Privacy
|
||||
|
||||
let etag = function
|
||||
| Terms -> Config.terms_etag
|
||||
| Privacy -> Config.privacy_etag
|
||||
| Terms -> Config.Exchange.terms_etag
|
||||
| Privacy -> Config.Exchange.privacy_etag
|
||||
|
||||
let legal_version = function
|
||||
| Terms -> Config.terms_legal_version
|
||||
| Privacy -> Config.privacy_legal_version
|
||||
| Terms -> terms_legal_version
|
||||
| Privacy -> privacy_legal_version
|
||||
|
||||
let base_dir = function
|
||||
| Terms -> Config.terms_dir
|
||||
| Privacy -> Config.privacy_dir
|
||||
| Terms -> Config.Exchange.terms_dir
|
||||
| Privacy -> Config.Exchange.privacy_dir
|
||||
|
||||
(* TODO
|
||||
better use of Fmt to have error prefix or smthing
|
||||
|
|
@ -107,8 +98,8 @@ let supported_lang_arr, supported_ext_arr =
|
|||
let () =
|
||||
if List.is_empty lang_l then Fmt.failwith "no language supported";
|
||||
if List.is_empty ext_l then Fmt.failwith "no mimetype supported";
|
||||
if not @@ List.mem Config.default_lang lang_l then
|
||||
Fmt.failwith "default language `%s` files not found" Config.default_lang;
|
||||
if not @@ List.mem default_lang lang_l then
|
||||
Fmt.failwith "default language `%s` files not found" default_lang;
|
||||
if not @@ List.mem ".txt" ext_l then
|
||||
Fmt.failwith "plain text file not found";
|
||||
if not @@ List.mem ".md" ext_l then Fmt.failwith "markdown file not found";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue