navigation

Controller

Namespace: Saturn
Parent: ControllerHelpers

Module containing helpers for controller actions


Values and Functions
Name Description
json ctx obj
Signature: ctx:HttpContext -> obj:'a -> Task

Returns to the client content serialized to JSON.

jsonCustom ctx settings obj
Signature: ctx:HttpContext -> settings:'?42468 -> obj:'?42469 -> Task

Returns to the client content serialized to JSON. Accepts custom serialization settings

xml ctx obj
Signature: ctx:HttpContext -> obj:'a -> Task

Returns to the client content serialized to XML.

text ctx value
Signature: ctx:HttpContext -> value:string -> Task

Returns to the client content as string.

html ctx template
Signature: ctx:HttpContext -> template:string -> Task

Returns the string template as html to the client.

renderHtml ctx template
Signature: ctx:HttpContext -> template:XmlNode -> Task

Returns to the client rendered html template.

file ctx path
Signature: ctx:HttpContext -> path:string -> Task

Returns to the client static file.

response ctx output
Signature: ctx:HttpContext -> output:'a -> Task

Returns to the client response according to accepted content type (Accept header, and if it's not present Content-Type header)

getJson(ctx)
Signature: ctx:HttpContext -> Task<'a>

Gets model from body as JSON.

getXml(ctx)
Signature: ctx:HttpContext -> Task<'a>

Gets model from body as XML.

getForm(ctx)
Signature: ctx:HttpContext -> Task<'a>

Gets model from urelencoded body.

getFormCulture ctx culture
Signature: ctx:HttpContext -> culture:string -> Task<'a>

Gets model from urelencoded body. Accepts culture name

getQuery(ctx)
Signature: ctx:HttpContext -> 'a

Gets model from query string.

getQueryCulture ctx culture
Signature: ctx:HttpContext -> culture:string -> 'a

Gets model from query string. Accepts culture name

getModel(ctx)
Signature: ctx:HttpContext -> Task<'a>

Get model based on HttpMethod and Content-Type of request.

getModelCustom ctx culture
Signature: ctx:HttpContext -> culture:string option -> Task<'a>

Get model based on HttpMethod and Content-Type of request. Accepts custom culture.

loadModel(ctx)
Signature: ctx:HttpContext -> 'a option

Loads model populated by fetchModel pipeline

getPath(ctx)
Signature: ctx:HttpContext -> string

Gets path of the request - it's relative to current scope

getUrl(ctx)
Signature: ctx:HttpContext -> string option

Gets url of the request

getConfig(ctx)
Signature: ctx:HttpContext -> 'a

Gets the contents of the Configuration key in the HttpContext dictionary, unboxed as the given type.

sendDownload ctx path
Signature: ctx:HttpContext -> path:string -> HttpFuncResult

Sends the contents of a file as the body of the response. Does not set a Content-Type.

sendDownloadBinary ctx content
Signature: ctx:HttpContext -> content:byte [] -> HttpFuncResult

Send bytes as the body of the response. Does not set a Content-Type.

redirect ctx path
Signature: ctx:HttpContext -> path:string -> HttpFuncResult

Perform a temporary redirect to the provided location.