package sihl

  1. Overview
  2. Docs
The modular functional web framework

Install

Dune Dependency

Authors

Maintainers

Sources

sihl-0.1.3.tbz
sha256=3d1acdd1eae24a7131033656f90b5d20c1621e6ef92957edf88a09b8b5f2d9e9
sha512=d224f54e20a9465c7a03d534dadcb2b9a181ae87c13731840db945aab37534f6f3982c5cb25a197e90c17d8772da062b19fa92bb93ed53a8b736c3776a7776db

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.