navigation

PipelineBuilder

Namespace: Saturn
Parent: Pipeline

Computation expression used to combine HttpHandlers in a declarative manner.

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

Example:

let headerPipe = pipeline {
    set_header "myCustomHeader" "abcd"
    set_header "myCustomHeader2" "zxcv"
}

let endpointPipe = pipeline {
    plug fetchSession
    plug head
    plug requestId
}
val headerPipe : obj
val endpointPipe : obj

Name Description
Instance Members
x.Challenge(state, scheme)
Signature: (state:HttpHandler * scheme:string) -> HttpHandler


CE Custom Operation: challenge

challenge challenges an authentication with a specified authentication scheme

x.ClearResponse(state)
Signature: state:HttpHandler -> HttpHandler


CE Custom Operation: clear_response

clear_response tries to clear the current response. This can be useful inside an error handler to reset the response before writing an error message to the body of the HTTP response object.

x.Html(state, cnt)
Signature: (state:HttpHandler * cnt:string) -> HttpHandler


CE Custom Operation: html

html sets or modifies the body of the HttpResponse with the contents of a single string variable. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

x.HtmlFile(state, fileName)
Signature: (state:HttpHandler * fileName:string) -> HttpHandler


CE Custom Operation: html_file

html_file sets or modifies the body of the HttpResponse with the contents of a physical html file. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. This http handler takes a rooted path of a html file or a path which is relative to the ContentRootPath as the input parameter and sets the HTTP header Content-Type to text/html.

x.Json(state, cnt)
Signature: (state:HttpHandler * cnt:'?42672) -> HttpHandler


CE Custom Operation: json

json sets or modifies the body of the HttpResponse by sending a JSON serialized object to the client. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. It also sets the Content-Type HTTP header to application/json.

x.MustAccept(state, accepts)
Signature: (state:HttpHandler * accepts:string list) -> HttpHandler


CE Custom Operation: must_accept

must_accept filters a request by the Accept HTTP header. You can use it to check if a client accepts a certain mime type before returning a response.

x.Negotiate(state, cnt)
Signature: (state:HttpHandler * cnt:'?42676) -> HttpHandler


CE Custom Operation: negotiate

negotiate sets or modifies the body of the HttpResponse by inspecting the Accept header of the HTTP request and deciding if the response should be sent in JSON or XML or plain text. If the client is indifferent then the default response will be sent in JSON. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

x.NegotiateWith(state, rules, unaccepted, cnt)
Signature: (state:HttpHandler * rules:IDictionary HttpHandler)> * unaccepted:HttpHandler * cnt:'?42678) -> HttpHandler


CE Custom Operation: negotiate_with

negotiateWith sets or modifies the body of the HttpResponse by inspecting the Accept header of the HTTP request and deciding in what mimeType the response should be sent. A dictionary of type IDictionary<string, obj -> HttpHandler> is used to determine which obj -> HttpHandler function should be used to convert an object into a HttpHandler for a given mime type. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

x.Plug(state, plug)
Signature: (state:HttpHandler * plug:HttpHandler) -> HttpHandler


CE Custom Operation: plug

plug enables adding any additional HttpHandler to the pipeline

x.RedirectTo(state, pernament, location)
Signature: (state:HttpHandler * pernament:bool * location:string) -> HttpHandler


CE Custom Operation: redirect_to

redirect_to uses a 302 or 301 (when permanent) HTTP response code to redirect the client to the specified location. It takes in two parameters, a boolean flag denoting whether the redirect should be permanent or not and the location to redirect to.

x.RenderHtml(state, cnt)
Signature: (state:HttpHandler * cnt:XmlNode) -> HttpHandler


CE Custom Operation: render_html

render_html is a more functional way of generating HTML by composing HTML elements in F# to generate a rich Model-View output.

x.RequiresAuthPolicy(state, check, authFailedHandler)
Signature: (state:HttpHandler * check:(ClaimsPrincipal -> bool) * authFailedHandler:HttpHandler) -> HttpHandler


CE Custom Operation: requires_auth_policy

requires_auth_policy validates if a user satisfies policy requirement, if not then the handler will execute the authFailedHandler function.

x.RequiresAuthentication(state, authFailedHandler)
Signature: (state:HttpHandler * authFailedHandler:HttpHandler) -> HttpHandler


CE Custom Operation: requires_authentication

requires_authentication validates if a user is authenticated/logged in. If the user is not authenticated then the handler will execute the authFailedHandler function.

x.RequiresPolicy(state, policy, authFailedHandler)
Signature: (state:HttpHandler * policy:string * authFailedHandler:(('?42660 -> Task<'?42660 option>) -> HttpContext -> HttpFuncResult)) -> HttpHandler


CE Custom Operation: requires_policy

requires_policy validates if a user satisfies a defined policy requirement, if not then the handler will execute the authFailedHandler function.

x.RequiresRole(state, role, authFailedHandler)
Signature: (state:HttpHandler * role:string * authFailedHandler:HttpHandler) -> HttpHandler


CE Custom Operation: requires_role

requires_role validates if an authenticated user is in a specified role. If the user fails to be in the required role then the handler will execute the authFailedHandler function.

x.RequiresRoleOf(state, roles, authFailedHandler)
Signature: (state:HttpHandler * roles:string list * authFailedHandler:HttpHandler) -> HttpHandler


CE Custom Operation: requires_role_of

requires_role_of validates if an authenticated user is in one of the supplied roles. If the user fails to be in one of the required roles then the handler will execute the authFailedHandler function.

x.RoutePorts(state, handlersByPorts)
Signature: (state:HttpHandler * handlersByPorts:(int * HttpHandler) list) -> HttpHandler


CE Custom Operation: route_ports

If your web server is listening to multiple ports then you can use the routePorts HttpHandler to easily filter incoming requests based on their port by providing a list of port number and HttpHandler ((int * HttpHandler) list).

x.SetBody(state, value)
Signature: (state:HttpHandler * value:byte array) -> HttpHandler


CE Custom Operation: set_body

set_body sets or modifies the body of the HttpResponse. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

x.SetBodyFromString(state, value)
Signature: (state:HttpHandler * value:string) -> HttpHandler


CE Custom Operation: set_body_from_string

set_body_from_string sets or modifies the body of the HttpResponse. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more.

x.SetHeader(state, key, value)
Signature: (state:HttpHandler * key:string * value:'?42667) -> HttpHandler


CE Custom Operation: set_header

set_header sets or modifies a HTTP header of the HttpResponse.

x.SetStatusCode(state, code)
Signature: (state:HttpHandler * code:int) -> HttpHandler


CE Custom Operation: set_status_code

set_status_code changes the status code of the HttpResponse.

x.SignOff(state, scheme)
Signature: (state:HttpHandler * scheme:string) -> HttpHandler


CE Custom Operation: sign_off

sign_off signs off the currently logged in user.

x.Text(state, cnt)
Signature: (state:HttpHandler * cnt:string) -> HttpHandler


CE Custom Operation: text

text sets or modifies the body of the HttpResponse by sending a plain text value to the client. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. It also sets the Content-Type HTTP header to text/plain.

x.Warbler(state)
Signature: state:HttpHandler -> HttpHandler


CE Custom Operation: use_warbler

If your route is not returning a static response, then you should wrap your function with a warbler. Functions in F# are eagerly evaluated and the warbler will help to evaluate the function every time the route is hit.

x.Xml(state, cnt)
Signature: (state:HttpHandler * cnt:'?42674) -> HttpHandler


CE Custom Operation: xml

xml sets or modifies the body of the HttpResponse by sending an XML serialized object to the client. This http handler triggers a response to the client and other http handlers will not be able to modify the HTTP headers afterwards any more. It also sets the Content-Type HTTP header to application/xml.

x.Yield(arg1)
Signature: '?42653 -> HttpHandler