navigation

RouterBuilder

Namespace: Saturn.Endpoint
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.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<'?41075,'?41076,'?41077,'?41078,'?41079> * action:('?41079 -> HttpHandler)) -> RouterState


CE Custom Operation: deletef

Adds handler for DELETE request.

x.Forward(state, path, actions)
Signature: (state:RouterState * path:string * actions:Endpoint list) -> RouterState

Forwards calls to different list of Endpoint.

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


CE Custom Operation: forward

Forwards calls to different Endpoint.

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<'?41054,'?41055,'?41056,'?41057,'f> * action:('f -> HttpHandler)) -> RouterState


CE Custom Operation: getf

Adds handler for GET request.

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<'?41082,'?41083,'?41084,'?41085,'?41086> * action:('?41086 -> 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<'?41061,'?41062,'?41063,'?41064,'?41065> * action:('?41065 -> 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<'?41068,'?41069,'?41070,'?41071,'?41072> * action:('?41072 -> HttpHandler)) -> RouterState


CE Custom Operation: putf

Adds handler for PUT request.

x.Run(state)
Signature: state:RouterState -> Endpoint list

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