add headers_lib
This commit is contained in:
parent
72426790b4
commit
4cbf3c722c
6 changed files with 110 additions and 92 deletions
|
|
@ -29,16 +29,13 @@ module Static = struct
|
|||
| Error e -> Fmt.failwith "TODO handle me, %s" e
|
||||
| Ok v -> v
|
||||
in
|
||||
let etag =
|
||||
(* TODO keep our static asset etag as Etag.t in Config? *)
|
||||
Assets.etag kind |> Headers.Etag.of_crockford32 |> Result.get_ok
|
||||
in
|
||||
let etag = Assets.etag kind in
|
||||
let headers = Vif.Request.headers req in
|
||||
let has_matching_etag =
|
||||
match Vif.Headers.get headers "if-none-match" with
|
||||
| None -> false
|
||||
| Some s ->
|
||||
s |> Headers.Etag.parse |> get_ok |> Headers.Etag.evaluate etag
|
||||
Headers_lib.Etag.parse s |> get_ok |> Headers_lib.Etag.evaluate etag
|
||||
in
|
||||
match has_matching_etag with
|
||||
| true ->
|
||||
|
|
@ -54,7 +51,7 @@ module Static = struct
|
|||
let open Vif.Response.Syntax in
|
||||
let* () = Vif.Response.with_string ?compression req data in
|
||||
let* () =
|
||||
let etag_field_value = Headers.Etag.to_field_value etag in
|
||||
let etag_field_value = Headers_lib.Etag.to_field_value etag in
|
||||
Vif.Response.add ~field:"etag" etag_field_value
|
||||
in
|
||||
let* () =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue