package sihl

  1. Overview
  2. Docs
The modular functional web framework

Install

Dune Dependency

Authors

Maintainers

Sources

sihl-0.1.4.tbz
sha256=49fe887d05083b37523cd6e7ca35239822c561fe7109dd383c30aeb4259a7b98
sha512=4135ad42a75fb9adc3e853a466b696d9ee6d7a9d8acf0cee9fd5f5485679a517f524ce704e2d153df4a7c4f1d14df9f94ab2a8fbe5b36e744b505daab1d40f3d

doc/sihl.app/App/index.html

Module AppSource

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)
Sourcemodule Make (Kernel : sig ... end) : sig ... end

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
OCaml

Innovation. Community. Security.