package sihl
The modular functional web framework
Install
Dune Dependency
Authors
Maintainers
Sources
sihl-queue-0.1.6.tbz
sha256=574c73c97ea0bc57144853b28df6125855a040ef0378f3bf180b4331dde93f9d
sha512=92c474ed3b6609395799f77259fc424af37dcad53095773ca2f2cdd4757a1607a5b53b6594cd7b6ddabeb40ebba67bb9544ff0f31dc228c87cfe015afa520aaa
doc/src/sihl.http/service.ml.html
Source file service.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
let to_opium_builder (meth, path, handler) = let open Route in match meth with | Get -> Opium.Std.get path handler | Post -> Opium.Std.post path handler | Put -> Opium.Std.put path handler | Delete -> Opium.Std.delete path handler | Any -> Opium.Std.all path handler ;; let routers_to_opium_builders routers = routers |> List.map (fun router -> let routes = Route.router_to_routes router in List.map to_opium_builder routes) |> List.concat ;; let run_forever () = let p, _ = Lwt.wait () in p ;; type config = { port : int option } let config port = { port } let schema = let open Conformist in make [ optional (int "PORT") ] config ;; let routers = ref [] let start_server _ = Logs.debug (fun m -> m "WEB: Starting HTTP server"); let port_nr = Option.value (Core.Configuration.read schema).port ~default:33000 in let app = Opium.Std.App.(empty |> port port_nr |> cmd_name "Sihl App") in let builders = routers_to_opium_builders !routers in let app = List.fold_left (fun app builder -> builder app) app builders in (* We don't want to block here, the returned Lwt.t will never resolve *) let _ = Opium.Std.App.start app in run_forever () ;; let start_cmd = Core.Command.make ~name:"start" ~help:"" ~description:"Start the web server" (fun _ -> let ctx = Core.Ctx.create () in start_server ctx) ;; (* Lifecycle *) let start ctx = Lwt.return ctx let stop _ = Lwt.return () let lifecycle = Core.Container.Lifecycle.create "web-server" ~start ~stop let configure rs configuration = routers := rs; let configuration = Core.Configuration.make ~schema configuration in Core.Container.Service.create ~configuration ~commands:[ start_cmd ] lifecycle ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>