Writers Module

Module that allows changing the output response in different ways. Functions have signature f :: params... -> HttpContext -> HttpContext.

Functions and values

Function or value Description

addHeader key value

Full Usage: addHeader key value

Parameters:
    key : string
    value : string

Returns: WebPart

Adds the header key with the given value to the list of returned headers, even if that header already exists. This means that Suave will serve a a response with the header denoted by `key` with possibly different values. Also consider `setHeader` and `setHeaderValue` depending on what semantics you'd like. Furthermore, Cookies must be set on separate header lines (using this function) and not comma-concatenated. See https://github.com/SuaveIO/suave/issues/338#issuecomment-156820747 for defails.

key : string
value : string
Returns: WebPart

createMimeType name compression

Full Usage: createMimeType name compression

Parameters:
    name : string
    compression : bool

Returns: MimeType option

Creates a MIME type record

name : string
compression : bool
Returns: MimeType option

defaultMimeTypesMap ext

Full Usage: defaultMimeTypesMap ext

Parameters:
    ext : string

Returns: MimeType option

Map a file ending to a mime-type

ext : string
Returns: MimeType option

setHeader key value

Full Usage: setHeader key value

Parameters:
    key : string
    value : string

Returns: WebPart

Ensures that the header named by the `key` parameter has the given value, by removing any other headers with the same key from the response header list.

key : string
value : string
Returns: WebPart

setHeaderValue key value

Full Usage: setHeaderValue key value

Parameters:
    key : string
    value : string

Returns: WebPart

Ensures that the is unique in the comma-separated list of the response header, denoted by `key`. This is useful for example for the "Vary" header which should at the very minimum include "Accept-Encoding", but may also include "Accept-Language" for multi-lingual sites (see Suave.Locale repo) and "Authorization" and "Cookie" for authorized resources.

key : string
value : string
Returns: WebPart

setMimeType mimeType

Full Usage: setMimeType mimeType

Parameters:
    mimeType : string

Returns: WebPart

Set the Content-Type header to the mime type given. Remember that it should include the encoding of your content. So for example, specifying a mimeType value of 'application/json; charset=utf-8' is strongly recommended (but replace 'json' with your own MIME type, of course ;))

mimeType : string
Returns: WebPart

setStatus status

Full Usage: setStatus status

Parameters:
Returns: WebPart

Sets the HTTP response status

status : HttpCode
Returns: WebPart

setUserData key value

Full Usage: setUserData key value

Parameters:
    key : string
    value : 'T

Returns: WebPart

Sets a user data key-value pair with the key and value specified. Downstream web parts can read this.

key : string
value : 'T
Returns: WebPart

unsetUserData key

Full Usage: unsetUserData key

Parameters:
    key : string

Returns: WebPart

Unset the user data by the given key

key : string
Returns: WebPart