mime

package
v0.0.0-...-bb9e38b Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Took me a while to wrap my head around so here is a bit of an explanation for future reference. Think of Entity as an expanded definition of an RFC 5322 message. The basic syntax is: header + blank line + body.

The header may or may not contain MIME related headers, i.e. Content-* A multipart entity is just one with a Content-Type: multipart/*; boundary=* header along with a special body syntax, but otherwise still retains the basic header + blank line + (multipart-body) syntax

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectContentType

func DetectContentType(data []byte) (ctype string, charset string)

DetectContentType returns content type and charset if applicable It splits the two unlike http.DetectContentType

Types

type Entity

type Entity struct {
	Headers []header.Header
	Body    fmt.Stringer
}

Entity refers to MIME-defined header fields and contents can be either message entity or multipart entity

syntax:

entity-headers         :=   [ content CRLF ]
                            [ encoding CRLF ]
                            [ id CRLF ]
                            [ description CRLF ]
                            *( MIME-extension-field CRLF )
MIME-message-headers   :=   entity-headers
                            fields
                            version CRLF
MIME-part-headers      :=   entity-headers
                            [ fields ]

func NewEntity

func NewEntity(headers []header.Header, body string) *Entity

NewEntity creates a new entity where body is a simple string

func NewMultipart

func NewMultipart(subtype string, headers []header.Header, parts []*Entity) *Entity

NewMultipart returns an entity with content-type set as multipart/subtype

func NewMultipartAlternative

func NewMultipartAlternative(headers []header.Header, parts []*Entity) *Entity

NewMultipartAlternative returns multipart/alternative entity Parts should be in ascending (least to greatest) order of preference preference

func NewMultipartMixed

func NewMultipartMixed(headers []header.Header, parts []*Entity) *Entity

func NewMultipartRelated

func NewMultipartRelated(headers []header.Header, parts []*Entity) *Entity

func (*Entity) String

func (e *Entity) String() string

type String

type String string

func (String) String

func (s String) String() string

Jump to

Keyboard shortcuts

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