Module Sihl.Web
type meth
= Web.meth
=
|
Get
|
Head
|
Options
|
Post
|
Put
|
Patch
|
Delete
|
Any
HTTP method
type router
= Web.router
=
{
scope : string;
routes : route list;
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.
val get : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
get path ?middlewares handler
returns a router with a singleGET
route containing thehandler
. The scope of the router ispath
.
val head : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
head path ?middlewares handler
returns a router with a singleHEAD
route containing thehandler
. The scope of the router ispath
.
val options : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
options path ?middlewares handler
returns a router with a singleOPTIONS
route containing thehandler
. The scope of the router ispath
.
val post : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
post path ?middlewares handler
returns a router with a singlePOST
route containing thehandler
. The scope of the router ispath
.
val put : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
put path ?middlewares handler
returns a router with a singlePUT
route containing thehandler
. The scope of the router ispath
.
val patch : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
patch path ?middlewares handler
returns a router with a singlePATCH
route containing thehandler
. The scope of the router ispath
.
val delete : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
delete path ?middlewares handler
returns a router with a singleDELETE
route containing thehandler
. The scope of the router ispath
.
val any : string -> ?middlewares:Rock.Middleware.t list -> handler -> router
any path ?middlewares handler
returns a router with a single route containing thehandler
. The scope of the router ispath
. This route matches any HTTP method.
val routes_of_router : router -> route list
routes_of_router router
applies the middlewares, routes and the scope of arouter
and returns a list of routes.
val choose : ?scope:string -> ?middlewares:Rock.Middleware.t list -> router list -> router
choose ?scope ?middlewares routers
returns a router by combining a list ofrouters
.scope
is the new scope under which allrouters
are mounted.middlewares
is an optional list of middlewares that are applied for allrouters
. By default, this list is empty.routers
is the list of routers to combine.
val externalize_path : ?prefix:string -> string -> string
externalize_path ?prefix path
returns a path with aprefix
added.If no
prefix
is provided,PREFIX_PATH
is used. IfPREFIX_PATH
is not provided, the returned path equals the provided path.
module Request : sig ... end
module Http : sig ... end
module Csrf : sig ... end
module Flash : sig ... end
module Rest : sig ... end
This module allows you to build RESTful web pages quickly.
module Htmx : sig ... end
module Id : sig ... end
module Session : sig ... end
module Middleware : sig ... end