mimedb

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 6 Imported by: 0

README

go-mimedb

go-mimedb is a drop-in replacement for the mime package that is independent of external files.

Motivation

The mime package uses the local system's MIME-info database or mime.types file(s).

/usr/local/share/mime/globs2
/usr/share/mime/globs2
/etc/mime.types
/etc/apache2/mime.types
/etc/apache/mime.types

Therefore, it returns different results depending on the execution environment.

go-mimedb has a large build-in table and does not depend on these files.

Data Source of MIME-info database

MIME-info database comes from jshttp/mime-db.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddExtensionType added in v0.2.0

func AddExtensionType(ext, typ string) error

AddExtensionType is not supported by this package. MIE type database is read-only.

func ExtensionsByType

func ExtensionsByType(typ string) ([]string, error)

ExtensionsByType returns the extensions known to be associated with the MIME type typ. The returned extensions will each begin with a leading dot, as in ".html". When typ has no associated extensions, ExtensionsByType returns an nil slice.

func FormatMediaType added in v0.2.0

func FormatMediaType(t string, param map[string]string) string

FormatMediaType is an alias of mime.FormatMediaType.

func ParseMediaType added in v0.2.0

func ParseMediaType(v string) (mediatype string, params map[string]string, err error)

ParseMediaType is an alias of mime.ParseMediaType.

func TypeByExtension

func TypeByExtension(ext string) string

TypeByExtension returns the MIME type associated with the file extension ext. The extension ext should begin with a leading dot, as in ".html". When ext has no associated type, TypeByExtension returns "".

Extensions are looked up first case-sensitively, then case-insensitively.

Text types have the charset parameter set to "utf-8" by default.

Types

type WordDecoder added in v0.2.0

type WordDecoder = mime.WordDecoder

WordDecoder is an alias of mime.WordDecoder.

type WordEncoder added in v0.2.0

type WordEncoder = mime.WordEncoder

WordEncoder is an alias of mime.WordEncoder.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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