Documentation
¶
Overview ¶
Package mediatype provides an [Internet] Media Type model and MIME type string parser/formatter
Index ¶
- Constants
- type Immutable
- func (m *Immutable) FullType() string
- func (m *Immutable) MainType() string
- func (m *Immutable) Mutable() Mutable
- func (m *Immutable) Parameters() map[string]string
- func (m *Immutable) Prefix() string
- func (m *Immutable) String() string
- func (m *Immutable) SubType() string
- func (m *Immutable) Suffix() string
- func (m *Immutable) Trees() []string
- type MediaType
- func DetectFromBytes(data []byte) (MediaType, error)
- func DetectFromFileHeader(fileHeader multipart.FileHeader) (MediaType, error)
- func DetectFromHeader(header textproto.MIMEHeader) (MediaType, error)
- func NewImmutable() MediaType
- func NewImmutableAsContainer(mutable Mutable) MediaType
- func NewMutable() MediaType
- func Parse(raw string) (MediaType, error)
- type Mutable
- func (m *Mutable) FullType() string
- func (m Mutable) Immutable() *Immutable
- func (m *Mutable) MainType() string
- func (m *Mutable) Parameters() map[string]string
- func (m *Mutable) Prefix() string
- func (m *Mutable) String() string
- func (m *Mutable) SubType() string
- func (m *Mutable) Suffix() string
- func (m *Mutable) Trees() []string
Constants ¶
const ( // MainSubSplitCharacter - The character used to split the main and sub-types from a full type string MainSubSplitCharacter = "/" // SuffixCharacter - The character used to denote a suffix declaration SuffixCharacter = "+" // TreeSeparatorCharacter - The character used to separate trees TreeSeparatorCharacter = "." )
const ContentTypeHeader = "Content-Type"
ContentTypeHeader - The standard key of a MIMEHeader's content type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Immutable ¶
type Immutable struct {
// contains filtered or unexported fields
}
Immutable is an immutable encapsulation of a Media Type
func (*Immutable) Parameters ¶
Parameters returns the defined parameters of the media type
type MediaType ¶
type MediaType interface { fmt.Stringer MainType() string SubType() string Trees() []string Prefix() string Suffix() string Parameters() map[string]string FullType() string }
MediaType is the interface for an [Internet] Media Type model
Each method is a getter for each piece of a Media Type's structure ¶
The `String()` method implements the fmt.Stringer interface to easily print out the reconstructed parts of the MediaType model in a standards compliant manner, following the `mime.FormatMediaType()` output
func DetectFromBytes ¶
DetectFromBytes - Build a MediaType from the detected content type of a byte array
func DetectFromFileHeader ¶
func DetectFromFileHeader(fileHeader multipart.FileHeader) (MediaType, error)
DetectFromFileHeader - Build a MediaType from a FileHeader
func DetectFromHeader ¶
func DetectFromHeader(header textproto.MIMEHeader) (MediaType, error)
DetectFromHeader - Build a MediaType from a MIMEHeader map
func NewImmutable ¶
func NewImmutable() MediaType
NewImmutable returns a new empty instance of a Immutable struct
func NewImmutableAsContainer ¶
NewImmutableAsContainer returns a new instance of a Immutable struct with the values matching the values of the passed Mutable struct
func NewMutable ¶
func NewMutable() MediaType
NewMutable returns a new empty instance of a Mutable struct
type Mutable ¶
Mutable is a struct defining the components of a Media Type
func (*Mutable) Parameters ¶
Parameters returns the defined parameters of the media type