vif/examples/04-device/main.ml

28 lines
494 B
OCaml
Raw Normal View History

2025-02-01 15:54:10 +00:00
#require "vif" ;;
type foo = Foo ;;
let foo =
let finally Foo = () in
2025-02-02 12:29:07 +00:00
Vif.D.device ~name:"foo" ~finally [] @@ fun () -> Foo
2025-02-01 15:54:10 +00:00
;;
2025-02-13 16:17:00 +00:00
open Vif ;;
2025-02-18 18:25:30 +00:00
let default req server () =
2025-02-01 15:54:10 +00:00
let Foo = Vif.S.device foo server in
2025-02-13 16:17:00 +00:00
let* () = Response.with_string req "ok\n" in
Response.respond `OK
2025-02-01 15:54:10 +00:00
;;
2025-02-18 18:25:30 +00:00
let routes =
let open Vif.U in
let open Vif.R in
let open Vif.Content_type in
[ get (rel /?? nil) --> default ]
2025-02-01 15:54:10 +00:00
let () =
2025-02-18 18:25:30 +00:00
Miou_unix.run @@ fun () ->
Vif.run ~devices:Vif.Ds.[ foo ] routes ()
2025-02-01 15:54:10 +00:00
;;