mime-types-0.1.2.0: Basic mime-type handling types and functions

Safe Haskell | Safe-Inferred
Language | Haskell2010

Network.Mime

Contents

- Lookups
- Defaults
- Utilities
- Types

Synopsis

- mimeByExt :: MimeMap -> MimeType -> FileName -> MimeType
- defaultMimeLookup :: FileName -> MimeType
- defaultMimeType :: MimeType
- defaultMimeMap :: MimeMap
- defaultExtensionMap :: ExtensionMap
- fileNameExtensions :: FileName -> [Extension]
- type FileName = Text
- type MimeType = ByteString
- type MimeMap = Map Extension MimeType
- type Extension = Text
- type ExtensionMap = Map MimeType [Extension]

# Lookups

mimeByExt #

Arguments

:: MimeMap |
-> MimeType | default mime type
-> FileName |
-> MimeType |

Look up a mime type from the given mime map and default mime type.

defaultMimeLookup :: FileName -> MimeType #

`mimeByExt` applied to `defaultMimeType` and `defaultMimeMap`.

# Defaults

defaultMimeType :: MimeType #

The default fallback mime type "application/octet-stream".

defaultMimeMap :: MimeMap #

A default mapping from filename extension to mime type.

Generated from the Apache and nginx mime.types files.

defaultExtensionMap :: ExtensionMap #

A mapping of `MimeType` to a set of `Extension`s.

Since: 0.1.2.0

# Utilities

fileNameExtensions :: FileName -> [Extension] #

Get a list of all of the file name extensions.

    fileNameExtensions "foo.tar.gz" == ["tar.gz", "gz"]

# Types

type FileName = Text #

The filename component of a filepath, leaving off the directory but keeping all extensions.

type MimeType = ByteString #

Individual mime type for be served over the wire.

type MimeMap = Map Extension MimeType #

Maps extensions to mime types.

type Extension = Text #

Path extension. May include multiple components, e.g. tar.gz

type ExtensionMap = Map MimeType [Extension] #

Maps mime types to extensions. The list of extensions is in alphabetical order.

Since: 0.1.2.0