navigation

RouterBuilder

Namespace: Saturn
Parent: Router

Computation expression used to create routing, combining HttpHandlers, pipelines and controllers together.

The result of the computation expression is a standard Giraffe HttpHandler, which means that it's easily composable with other parts of the ecosytem.

Example:

let topRouter = router {
    pipe_through headerPipe
    not_found_handler (text "404")

    get "/" helloWorld
    get "/a" helloWorld2
    getf "/name/%s" helloWorldName
    getf "/name/%s/%i" helloWorldNameAge

    //routers can be defined inline to simulate `subRoute` combinator
    forward "/other" (router {
        pipe_through otherHeaderPipe
        not_found_handler (text "Other 404")

        get "/" otherHelloWorld
        get "/a" otherHelloWorld2
    })

    // or can be defined separatly and used as HttpHandler
    forward "/api" apiRouter

    // same with controllers
    forward "/users" userController
}
val topRouter : obj

Name Description
Instance Members
x.CaseInsensitive(state)
Signature: state:RouterState -> RouterState


CE Custom Operation: case_insensitive

Toggle case insensitve routing

x.Delete(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: delete

Adds handler for DELETE request.

x.DeleteF(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42586,'?42587,'?42588,'?42589,'?42590> * action:('?42590 -> HttpHandler)) -> RouterState


CE Custom Operation: deletef

Adds handler for DELETE request.

x.Forward(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: forward

Forwards calls to different scope. Modifies the HttpRequest.Path to allow subrouting.

x.Forwardf(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42600,'?42601,'?42602,'?42603,'?42604> * action:('?42604 -> HttpHandler)) -> RouterState


CE Custom Operation: forwardf

Forwards calls to different scope. Modifies the HttpRequest.Path to allow subrouting.

x.Get(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: get

Adds handler for GET request.

x.GetF(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42565,'?42566,'?42567,'?42568,'f> * action:('f -> HttpHandler)) -> RouterState


CE Custom Operation: getf

Adds handler for GET request.

x.NotFoundHandler(state, handler)
Signature: (state:RouterState * handler:HttpHandler) -> RouterState


CE Custom Operation: not_found_handler

Adds not-found handler for current scope

x.Patch(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: patch

Adds handler for PATCH request.

x.PatchF(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42593,'?42594,'?42595,'?42596,'?42597> * action:('?42597 -> HttpHandler)) -> RouterState


CE Custom Operation: patchf

Adds handler for PATCH request.

x.PipeThrough(state, pipe)
Signature: (state:RouterState * pipe:HttpHandler) -> RouterState


CE Custom Operation: pipe_through

Adds pipeline to the list of pipelines that will be used for every request

x.Post(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: post

Adds handler for POST request.

x.PostF(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42572,'?42573,'?42574,'?42575,'?42576> * action:('?42576 -> HttpHandler)) -> RouterState


CE Custom Operation: postf

Adds handler for POST request.

x.Put(state, path, action)
Signature: (state:RouterState * path:string * action:HttpHandler) -> RouterState


CE Custom Operation: put

Adds handler for PUT request.

x.PutF(state, path, action)
Signature: (state:RouterState * path:PrintfFormat<'?42579,'?42580,'?42581,'?42582,'?42583> * action:('?42583 -> HttpHandler)) -> RouterState


CE Custom Operation: putf

Adds handler for PUT request.

x.Run(state)
Signature: state:RouterState -> HttpHandler

x.Yield(arg1)
Signature: '?42561 -> RouterState