implement redirection when user should be logged in/logged out
This commit is contained in:
parent
3f4c1b063e
commit
078b679bc2
4 changed files with 45 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue