package sihl

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module SihlSource

Sihl is a high-level web application framework providing a set of composable building blocks and recipes that allow you to develop web apps quickly and sustainably. Statically typed functional programming with OCaml makes web development fun and safe.

Things like database migrations, HTTP routing, user management, sessions, logging, emailing, job queues and schedules are just a few of the topics Sihl takes care of.

Let's have a look at a tiny Sihl app in a file called sihl.ml:

module Service = struct
  module Random = Sihl.Utils.Random.Service
  module Log = Sihl.Log.Service
  module Config = Sihl.Config.Service
  module Db = Sihl.Data.Db.Service
  module MigrationRepo = Sihl.Data.Migration.Service.Repo.MariaDb
  module Cmd = Sihl.Cmd.Service
  module Migration = Sihl.Data.Migration.Service.Make (Cmd) (Db) (MigrationRepo)
  module WebServer = Sihl.Web.Server.Service.Make (Cmd)
  module Schedule = Sihl.Schedule.Service.Make (Log)
end

let services : (module Sihl.Core.Container.SERVICE) list =
  [ (module Service.WebServer) ]

let hello_page =
  Sihl.Web.Route.get "/hello/" (fun _ ->
      Sihl.Web.Res.(html |> set_body "Hello!") |> Lwt.return)

let routes = [ ("/page", [ hello_page ], []) ]

module App = Sihl.App.Make (Service)

let _ = App.(empty |> with_services services |> with_routes routes |> run)

Core

Sourcemodule Core = Core

Sihl App

Sourcemodule App = App

Utils & Helpers

Sourcemodule Utils = Utils

Configuration

Sourcemodule Config = Configuration

Logging

Sourcemodule Log = Log

Data

Sourcemodule Data = Data

Web

Sourcemodule Web = Web

CLI Command

Sourcemodule Cmd = Cmd

Scheduler

Sourcemodule Schedule = Schedule

Authorization

Sourcemodule Authz = Authz

Token

Sourcemodule Token = Token

Authentication

Sourcemodule Authn = Authn

Emailing

Sourcemodule Email = Email

Session

Sourcemodule Session = Session

Message

Sourcemodule Message = Message

Storage

Sourcemodule Storage = Storage

User Management

Sourcemodule User = User

Job Queue

Sourcemodule Queue = Queue
OCaml

Innovation. Community. Security.