implement redirection when user should be logged in/logged out

This commit is contained in:
zapashcanon 2023-01-09 03:37:01 +01:00
parent 3f4c1b063e
commit 078b679bc2
No known key found for this signature in database
GPG key ID: 8981C3C62D1D28F1
4 changed files with 45 additions and 11 deletions

View file

@ -1,6 +1,16 @@
(* let bindings for early return when encountering an error *)
(* see https://ocaml.org/releases/4.13/htmlman/bindingops.html *)
let ( let* ) o f = Result.fold ~ok:f ~error:Result.error o
let ( let** ) o f = match o with Error e -> Template.err e | Ok v -> f v
type extended_status =
[ Dream.status
| `See_Other_Redirect of (string * string) list
]
let ( let** ) o f =
match o with
| Error (kind, msg) -> begin
match kind with
| `See_Other_Redirect headers ->
Dream.respond ~status:`See_Other ~headers msg
| #Dream.status as status -> Template.err (status, msg)
end
| Ok v -> f v