FSharpx.Extras


Conneg Module

Functions and values

Function or value Description

bestCharset x

Full Usage: bestCharset x

Parameters:
    x : string list -

Returns: string -> (string * float) option

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

x : string list

Returns: string -> (string * float) option

bestEncoding x

Full Usage: bestEncoding x

Parameters:
    x : string list

Returns: string -> (string * float) option
x : string list
Returns: string -> (string * float) option

bestLanguage x

Full Usage: bestLanguage x

Parameters:
    x : string seq -

Returns: string -> (string * float) option

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

x : string seq

Returns: string -> (string * float) option

bestMediaType x

Full Usage: bestMediaType x

Parameters:
    x : string seq

Returns: string -> (string * float) option

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

x : string seq
Returns: string -> (string * float) option

bestOf negotiate serves accepts

Full Usage: bestOf negotiate serves accepts

Parameters:
    negotiate : 'a -> 'b -> 'c list -
    serves : 'a -
    accepts : 'b -

Returns: 'c option

Gets the first item from a list of negotiated items

negotiate : 'a -> 'b -> 'c list

serves : 'a

accepts : 'b

Returns: 'c option

filterMediaTypes mediaType accepts

Full Usage: filterMediaTypes mediaType accepts

Parameters:
    mediaType : string -
    accepts : string -

Returns: (string * float) list

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

mediaType : string

accepts : string

Returns: (string * float) list

filterSortAccept

Full Usage: filterSortAccept

Returns: (string * float * float) seq -> (string * float) 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)

Returns: (string * float * float) seq -> (string * float) list

matchCharset serves accepts

Full Usage: matchCharset serves accepts

Parameters:
    serves : string -
    accepts : string -

Returns: string option

Matches two charset tags

serves : string

accepts : string

Returns: string option

matchLanguage serves accepts

Full Usage: matchLanguage serves accepts

Parameters:
    serves : string -
    accepts : string -

Returns: string option

Matches two language tags

serves : string

accepts : string

Returns: string option

matchMediaType serves accepts

Full Usage: matchMediaType serves accepts

Parameters:
    serves : string -
    accepts : string -

Returns: 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"

serves : string

accepts : string

Returns: string option

negotiate matcher serves accepts

Full Usage: negotiate matcher serves accepts

Parameters:
    matcher : 'a -> string -> 'b option -
    serves : 'a seq -
    accepts : string -

Returns: ('b * float) list

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

matcher : 'a -> string -> 'b option

serves : 'a seq

accepts : string

Returns: ('b * float) list

negotiateCharset x

Full Usage: negotiateCharset x

Parameters:
    x : string list

Returns: string -> (string * float) list

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

x : string list
Returns: string -> (string * float) list

negotiateEncoding x

Full Usage: negotiateEncoding x

Parameters:
    x : string list

Returns: string -> (string * float) list
x : string list
Returns: string -> (string * float) list

negotiateLanguage x

Full Usage: negotiateLanguage x

Parameters:
    x : string seq -

Returns: string -> (string * float) list

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

x : string seq

Returns: string -> (string * float) list

negotiateList matcher serves accepts

Full Usage: negotiateList matcher serves accepts

Parameters:
    matcher : 'a -> 'b -> ('c * 'd) option -
    serves : 'a seq -
    accepts : 'b seq -

Returns: ('c * 'd) list

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

matcher : 'a -> 'b -> ('c * 'd) option

serves : 'a seq

accepts : 'b seq

Returns: ('c * 'd) list

negotiateMediaType x

Full Usage: negotiateMediaType x

Parameters:
    x : string seq

Returns: string -> (string * float) list

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

x : string seq
Returns: string -> (string * float) list

parseAccept

Full Usage: parseAccept

Returns: string -> (string * float * float) seq

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

Returns: string -> (string * float * float) seq

parseFilterSortAccept

Full Usage: parseFilterSortAccept

Returns: string -> (string * float) list

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

Returns: string -> (string * float) list

parseMediaTypes

Full Usage: parseMediaTypes

Returns: string -> (string * (string * string) * float) list

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

Returns: string -> (string * (string * string) * float) list

parseQ s

Full Usage: parseQ s

Parameters:
    s : string[] - Header item split by ';'

Returns: string * float * float

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

s : string[]

Header item split by ';'

Returns: string * float * float

splitMediaTypeSubtype m

Full Usage: splitMediaTypeSubtype m

Parameters:
    m : string -

Returns: string * string

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

m : string

Returns: string * string

Active patterns

Active pattern Description

(|AcceptsMedia|_|) serves accepts

Full Usage: (|AcceptsMedia|_|) serves accepts

Parameters:
    serves : string -
    accepts : string list -

Returns: unit option

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

serves : string

accepts : string list

Returns: unit option