libmime

package
v1.0.48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2018 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Patch

func Patch(additional map[string]string, override Overrider)

Patch patches the mime types Go uses by calling mime.AddExtensionType on each from a private list in this package. Both parameters are optional. Provide a non-nil additional map (ext->mimeType) to add additional mime types. Provide a non-nil Overrider to override any mime type defined in the list. Note that the Overrider can override what's in the additional too.

Overrider is different from additional in the way that, additional provides exact ext-mimeType pairs, while overrider allows the user of this function to examine ext-mimeTypes flexibly. For example, this allows overrider to replace mimeTypes without an exaustive list of all extensions that resolve to it. So why is additional useful? Go's mime package loads mime types from a few filesystem locations such as /etc/apache2/mime.types. This happens inside the mime package and is beyond our control. So having additional here allows user to guard against unwanted mime types that may exist in one of mime type files.

Types

type Overrider

type Overrider func(ext string, mimeType string) (newExt string, newMimeType string)

Overrider defines a type that overrides a <ext, mimeType> mapping.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL