package sihl
The modular functional web framework
Install
Dune Dependency
Authors
Maintainers
Sources
sihl-0.1.1.tbz
sha256=eac58e5ee9c869aa3b0f0bcee936b01c53bf7fe1febb42edd607268dfb11f4e9
sha512=012b6cf1cf6af0966059761b4916ea8aa590aa8d5809a6f480cb17e23ee10c3b9245062c4f0cf9ad98ab950391c0827c9780999d39fa16a93f7aab4b12f9ab8c
doc/sihl.app/App/index.html
Module App
Source
A Sihl app is something that can be started and stopped and that users can interact with through HTTP or CLI commands. It contains configuration, HTTP endpoints, a list of services, schedules and CLI commands.
Kernel services
An app requires a minimal set of services. That set is called kernel services. Kernel service implementations are provided by Sihl, so you don't need any external dependencies to get started with Sihl apps.
App creation
After implementing domain services which makes an app that solves a particular problem, you want to expose it to users by creating a Sihl app.
Once you have set up the kernel services, use the functor Sihl.App.Make
to instantiate an app like follows:
module KernelServices = struct
module Random = Sihl.Utils.Random.Service.Make ()
module Log = Sihl.Log.Service.Make ()
module Config = Sihl.Config.Service.Make ()
module Db = Sihl.Data.Db.Service.Make ()
module MigrationRepo = Sihl.Data.Migration.Service.Repo.MakeMariaDb (Db)
module Cmd = Sihl.Cmd.Service.Make ()
module Migration = Sihl.Data.Migration.Service.Make (Log) (Cmd) (Db) (MigrationRepo)
module WebServer = Sihl.Web.Server.Service.Make (Log) (Cmd)
module Schedule = Sihl.Schedule.Service.Make (Log)
end
module App = Sihl.App.Make (KernelServices)
Usage
An app can be set up using a clean builder pattern. Make sure to call run
in the end:
let services = ...
let endpoints = ...
let config = ...
let schedules = ...
let commands = ...
let () =
App.(
empty
|> with_services services
|> with_endpoints endpoints
|> with_config config
|> with_schedules schedules
|> with_commands commands
|> run)
module Sig : sig ... end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page