Documentation ¶
Index ¶
- Constants
- Variables
- type Object
- type ObjectHeader
- type Part
- type Reader
- type Writer
- func (w *Writer) Boundary() string
- func (w *Writer) Close() error
- func (w *Writer) CreatePart(contentId string, header textproto.MIMEHeader) (io.Writer, error)
- func (w *Writer) CreateRoot(contentId string, mediaType string, header textproto.MIMEHeader) (io.Writer, error)
- func (w *Writer) FormDataContentType() string
- func (w *Writer) SetBoundary(boundary string) error
- func (w *Writer) SetStart(contentId string) error
- func (w *Writer) SetStartInfo(info string)
- func (w *Writer) SetType(mediaType string) error
Constants ¶
const DefaultMediaType = "text/plain; charset=utf-8"
DefaultMediaType
Variables ¶
var ( ErrTypeMatch = errors.New("root's media type doesn't match") ErrRootExists = errors.New("root part already exists") )
Errors introduced by the multipart/related.
var (
ErrDupRoot = errors.New("Detect duplicate roots")
)
Functions ¶
This section is empty.
Types ¶
type Object ¶
type Object struct {
Values []*ObjectHeader
}
A Object is parsed multipart/related compound object.
type ObjectHeader ¶
type ObjectHeader struct {
// contains filtered or unexported fields
}
A ObjectHeader describes a component of the aggregate whole of a multipart/related request.
type Part ¶
type Part struct { Header textproto.MIMEHeader Root bool // contains filtered or unexported fields }
A Part represents a single part in a multipart/related body
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an iterator over parts in a MIME multipart/related body.
func NewReader ¶
NewReader returns a new multipart/related Reader reading from r using the given MIME boundary. It's a wrapper around multipart's Reader
func (*Reader) NextPart ¶
NextPart returns the next part in the multipart/related or and error. When there are no more parts, the error io.EOF is returned.
func (*Reader) ReadObject ¶
ReadObject parses an entire multipart/related message.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
A Writer generates multipart/related messages. See http://tools.ietf.org/html/rfc2387
func NewWriter ¶
NewWriter returns a new multipart/related Writer with a random boundary, writing to w. It's a wrapper around multipart's Writer
func (*Writer) CreatePart ¶
CreatePart is a wrapper around mulipart's Writer.CreatePart
func (*Writer) CreateRoot ¶
func (w *Writer) CreateRoot( contentId string, mediaType string, header textproto.MIMEHeader, ) (io.Writer, error)
CreateRoot creates a new multipart/related root section with the provided contentId, mediaType and header. The body of the root should be written to the returned Writer.
header is used for adding additional information (e.g. Content- Transfer-Encoding), If Content-Id or Content-Type is specified in header, they will be overridden. If header is nil, creates a empty MIMEHeader.
func (*Writer) FormDataContentType ¶
FormDataContentType returns the Content-Type for a multipart/related with this Writer's Boundary, Start, Type and StartInfo.
func (*Writer) SetBoundary ¶
SetBoundary is a wrapper around multipart's Writer.SetBoundary
SetBoundary overrides the Writer's default randomly-generated boundary separator with an explicit value.
SetBoundary must be called before any parts are created, may only contain certain ASCII characters, and must be 1-69 bytes long.
func (*Writer) SetStartInfo ¶
SetStartInfo changes startInfo of the compound object