data

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 2 Imported by: 3

Documentation

Overview

Package data provides operations to deal with arbitrary data and MIME types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data map[Mime]io.ReadSeekCloser

Data represents arbitrary polymorphic data that can be used for data transfer between applications.

func Bytes

func Bytes(mime Mime, buffer []byte) Data

Bytes constructs a Data given a buffer and a mime type.

func Merge

func Merge(individual ...Data) (combined Data)

Merge combines several Datas together. If multiple Datas provide a reader for the same mime type, the ones further on in the list will take precedence.

func Text

func Text(text string) Data

Text returns plain text Data given a string.

type Mime

type Mime struct {
	// Type is the first half of the MIME type, and Subtype is the second
	// half. The separating slash is not included in either. For example,
	// text/html becomes:
	// Mime { Type: "text", Subtype: "html" }
	Type, Subtype string
}

Mime represents a MIME type.

func M

func M(ty, subtype string) Mime

M is shorthand for creating a MIME type.

func MimeFile

func MimeFile() Mime

MimeFile returns the MIME type of a file path/URI.

func MimePlain

func MimePlain() Mime

MimePlain returns the MIME type of plain text.

func (Mime) String

func (mime Mime) String() string

String returns the string representation of the MIME type.

Jump to

Keyboard shortcuts

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