add avail-languages header
This commit is contained in:
parent
0a0eac7cd9
commit
0447857d1e
2 changed files with 19 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
30
src/mte.ml
30
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 <https://www.gnu.org/licenses/>. *)
|
||||
|
||||
(* /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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue