diff --git a/src/headers.ml b/src/headers.ml index fa4bea84..68f974ba 100644 --- a/src/headers.ml +++ b/src/headers.ml @@ -1,3 +1,8 @@ +let avail_languages_header_value = + let pp_avail_languages = Fmt.array ~sep:(Fmt.any ", ") Fmt.string in + let s = Fmt.str "%a" pp_avail_languages Assets.supported_lang_arr in + s + let select_extension headers = let accept = Vif.Headers.get headers "accept" in Cohttp.Accept.media_ranges accept diff --git a/src/mte.ml b/src/mte.ml index 3afa7d3c..6cdbbb6e 100644 --- a/src/mte.ml +++ b/src/mte.ml @@ -13,6 +13,15 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . *) +(* /terms + /privacy + - try to find a response with an acceptable mime-type + - pick the version in the most preferred language of the user + - apply compression if that is allowed by the client + - set ETAG header + - If it did not change, a "304 Not Modified" response will be returned + - A "Taler-Terms-Version" header is generated to indicate the legal version of the terms + - When returning a full response (not a "304 Not Modified"), + include a "Avail-Languages" header: a comma-separated list of the languages available *) module Static = struct let select_file headers kind = let open Syntax in @@ -24,23 +33,8 @@ module Static = struct Option.to_result ~none:"no acceptable language" (Headers.select_language headers) in - let content = Assets.get_content ~lang ~ext kind in - content + Assets.get_content ~lang ~ext kind - (* /terms + /privacy - - - try to find a response with an acceptable mime-type, - - then pick the version in the most preferred language of the user, - - and finally apply compression if that is allowed by the client - - set ETAG header - - If it did not change, a "304 Not Modified" response will be returned - - A "Taler-Terms-Version" header is generated to indicate the legal version of the terms - - TODO: - - When returning a full response (not a "304 Not Modified"), the server - should also include a "Avail-Languages" header which includes a - comma-separated list of the languages in which the terms of service are available in - *) let static kind req _server _env = let get_ok = function | Error e -> Fmt.failwith "TODO handle me, %s" e @@ -75,6 +69,10 @@ module Static = struct Vif.Response.add ~field:"taler-terms-version" Config.terms_legal_version in + let* () = + Vif.Response.add ~field:"avail-languages" + Headers.avail_languages_header_value + in (* TODO content-type *) let* () = Vif.Response.add ~field:"content-type" "html; charset=utf-8"