package sihl

  1. Overview
  2. Docs

Module Sihl.WebSource

Sourcetype meth =
  1. | Get
  2. | Head
  3. | Options
  4. | Post
  5. | Put
  6. | Patch
  7. | Delete
  8. | Any

HTTP method

Sourcetype handler = Rock.Request.t -> Rock.Response.t Lwt.t

A handler returns a response given a request.

Sourcetype route = meth * string * handler

A route has an HTTP method, a path and a handler.

Sourcetype router = {
  1. scope : string;
  2. routes : route list;
  3. middlewares : Rock.Middleware.t list;
}

A router has a scope, a list of routes and a list of middlewares. A mounted router prefixes all routes and applies the middlewares to them.

Sourceval get : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

get path ?middlewares handler returns a router with a single GET route containing the handler. The scope of the router is path.

Sourceval head : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

head path ?middlewares handler returns a router with a single HEAD route containing the handler. The scope of the router is path.

Sourceval options : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

options path ?middlewares handler returns a router with a single OPTIONS route containing the handler. The scope of the router is path.

Sourceval post : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

post path ?middlewares handler returns a router with a single POST route containing the handler. The scope of the router is path.

Sourceval put : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

put path ?middlewares handler returns a router with a single PUT route containing the handler. The scope of the router is path.

Sourceval patch : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

patch path ?middlewares handler returns a router with a single PATCH route containing the handler. The scope of the router is path.

Sourceval delete : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

delete path ?middlewares handler returns a router with a single DELETE route containing the handler. The scope of the router is path.

Sourceval any : string -> ?middlewares:Rock.Middleware.t list -> handler -> router

any path ?middlewares handler returns a router with a single route containing the handler. The scope of the router is path. This route matches any HTTP method.

Sourceval routes_of_router : router -> route list

routes_of_router router applies the middlewares, routes and the scope of a router and returns a list of routes.

Sourceval choose : ?scope:string -> ?middlewares:Rock.Middleware.t list -> router list -> router

choose ?scope ?middlewares routers returns a router by combining a list of routers.

scope is the new scope under which all routers are mounted.

middlewares is an optional list of middlewares that are applied for all routers. By default, this list is empty.

routers is the list of routers to combine.

Sourceval externalize_path : ?prefix:string -> string -> string

externalize_path ?prefix path returns a path with a prefix added.

If no prefix is provided, PREFIX_PATH is used. If PREFIX_PATH is not provided, the returned path equals the provided path.

Sourcemodule Request : sig ... end
Sourcemodule Response = Opium.Response
Sourcemodule Body = Opium.Body
Sourcemodule Router = Opium.Router
Sourcemodule Route = Opium.Route
Sourcemodule Http : sig ... end
Sourcemodule Csrf : sig ... end
Sourcemodule Flash : sig ... end
Sourcemodule Rest : sig ... end

This module allows you to build RESTful web pages quickly.

Sourcemodule Htmx : sig ... end

This module simplifies dealing with HTMX requests by adding type safe helpers to manipulate HTMX headers. Visit https://htmx.org/reference/ for the HTMX documentation.

Sourcemodule Id : sig ... end
Sourcemodule Session : sig ... end
Sourcemodule Middleware : sig ... end
OCaml

Innovation. Community. Security.