lmug-mw-content-type

Middleware for automatically adding a content type to response maps.

add-content-type/2

(req resp)

The same as #'add-content-type/3 but with an empty list for options.

add-content-type/3

((match-request uri uri) resp opts)

Adds a content-type header to the response. Used by #'wrap/2.
Returns a response record.

wrap/1

(handler)

The same as #'wrap/2 but with an empty list for options.

wrap/2

(handler opts)

Middleware that adds a content-type header to the response if one is not
set by the handler. Uses #'lmug-util:ext->mime-type/1 to guess the
content-type from the file extension in the URI. If no content-type can be
found, it defaults to application/octet-stream.

Accepts the following options:

'mime-types - a proplist of filename extensions to mime-types that will be
used in addition to the ones retiurned by
lmug-util:get-default-mime-types/0. For the proper
formatting of the data, see the source for the
get-default-mime-types function mentioned above.