FSharpx.Extras


Conneg

Namespace: FSharpx.Http

Functions and values

Function or valueDescription
bestCharset x
Signature: x:string list -> string -> (string * float<MeasureOne>) option

Intersects accepted and served charsets. Returns the preferred viable charset, or None.

bestEncoding x
Signature: x:string list -> string -> (string * float<MeasureOne>) option
bestLanguage x
Signature: x:seq<string> -> string -> (string * float<MeasureOne>) option

Intersects accepted and served media. Returns the preferred viable language, or None.

bestMediaType x
Signature: x:seq<string> -> string -> (string * float<MeasureOne>) option

Intersects accepted and served media. Returns the preferred viable media, or None.

bestOf negotiate serves accepts
Signature: negotiate:('?11301 -> '?11302 -> '?11303 list) -> serves:'?11301 -> accepts:'?11302 -> '?11303 option
Type parameters: '?11301, '?11302, '?11303

Gets the first item from a list of negotiated items

filterMediaTypes mediaType accepts
Signature: mediaType:string -> accepts:string -> (string * float<MeasureOne>) list

Filters an Accept header by type. E.g. filterMediaTypes "image" "image/png,text/html" -> ["image/png"]

filterSortAccept
Signature: seq<string * float<MeasureOne> * float<MeasureOne>> -> (string * float<MeasureOne>) list

Takes a list of items with associated numeric quality (preference), and: removes all items with q=0 (i.e. not acceptable by client); sorts by q descending (client preference)

matchCharset serves accepts
Signature: serves:string -> accepts:string -> string option

Matches two charset tags

matchLanguage serves accepts
Signature: serves:string -> accepts:string -> string option

Matches two language tags

matchMediaType serves accepts
Signature: serves:string -> accepts:string -> string option

Finds a match between two media types, handling wildcards. Returns None if no match, otherwise Some media Example: matchMediaType "text/*" "text/plain" -> "text/plain"

negotiate matcher serves accepts
Signature: matcher:('?11297 -> string -> '?11298 option) -> serves:seq<'?11297> -> accepts:string -> ('?11298 * float<MeasureOne>) list
Type parameters: '?11297, '?11298

Filters and maps a list of served items and a Accept-* header of acceptable items using a matcher function

negotiateCharset x
Signature: x:string list -> string -> (string * float<MeasureOne>) list

Intersects accepted and served charsets. Returns a list of viable charsets, sorted by client preference in descending order

negotiateEncoding x
Signature: x:string list -> string -> (string * float<MeasureOne>) list
negotiateLanguage x
Signature: x:seq<string> -> string -> (string * float<MeasureOne>) list

Intersects accepted and served languages. Returns a list of viable languages, sorted by client preference in descending order

negotiateList matcher serves accepts
Signature: matcher:('?11292 -> '?11293 -> ('?11294 * '?11295) option) -> serves:seq<'?11292> -> accepts:seq<'?11293> -> ('?11294 * '?11295) list
Type parameters: '?11292, '?11293, '?11294, '?11295

Filters and maps two sequences of items using a matcher function.

negotiateMediaType x
Signature: x:seq<string> -> string -> (string * float<MeasureOne>) list

Intersects accepted and served media. Returns a list of viable media, sorted by client preference in descending order

parseAccept
Signature: string -> seq<string * float<MeasureOne> * float<MeasureOne>>

Parses any Accept-* header, returns a seq of items with associated q (quality/preference)

parseFilterSortAccept
Signature: string -> (string * float<MeasureOne>) list

Parses any Accept-* header. Removes all items with q=0 (i.e. not acceptable by client). Sorts by q descending (client preference)

parseMediaTypes
Signature: string -> (string * (string * string) * float<MeasureOne>) list

Parses an Accept header into a list of media,(media type, media subtype),q E.g. "text/html",("text","html"),0.8

parseQ s
Signature: s:string [] -> string * float<MeasureOne> * float<MeasureOne>

Parses a single Accept-* header item. Returns item with associated q

splitMediaTypeSubtype m
Signature: m:string -> string * string

Splits media type and subtype, e.g. "text/html" -> "text","html"

Active patterns

Active patternDescription
( |AcceptsMedia|_| ) serves accepts
Signature: serves:string -> accepts:string list -> unit option

Matches if the media parameter can be handled by the accept list

CompiledName: |AcceptsMedia|_|

Fork me on GitHub