datauri

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(u *url.URL) ([]byte, error)

Decode decodes the given data URI and returns the decoded bytes.

func GzipCompress

func GzipCompress(docBytes []byte) (string, error)

GzipCompress compresses the given content with gzip and returns a base64-encoded string.

func GzipDecompress

func GzipDecompress(content string) ([]byte, error)

GzipDecompress decompresses the given base64-encoded string with GZIP.

func MarshalCanonical

func MarshalCanonical(obj interface{}, dataType MediaType) (*url.URL, error)

MarshalCanonical marshals and encodes the given object using the given media type and returns a data URI with the encoded data. For example: 'data:application/gzip;base64,H4sIAbAAvAAA...'.

func New

func New(content []byte, dataType MediaType) (*url.URL, error)

New encodes the given content using the given media type and returns a data URI with the encoded data. For example: 'data:application/gzip;base64,H4sIAbAAvAAA...'.

Types

type MediaType

type MediaType = string

MediaType defines a type of encoding for content embedded within a data URI.

const (
	// MediaTypeDataURIJSON indicates that the contents of the data URL is a plain JSON string.
	MediaTypeDataURIJSON MediaType = "application/json"
	// MediaTypeDataURIGzipBase64 indicates that the contents of the data URL is compressed with gzip and base64-encoded.
	MediaTypeDataURIGzipBase64 MediaType = "application/gzip;base64"
)

Jump to

Keyboard shortcuts

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