contentdecoder

package
v0.0.0-...-3a583f3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package contentdecoder implement encoders and decoders for data by content types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(contentType string, rawBody io.Reader) (any, error)

Decode decodes the data by content type to arbitrary value.

func DecodeJSON

func DecodeJSON(r io.Reader) (any, error)

DecodeJSON decodes an arbitrary JSON from a reader stream.

func DecodeXML

func DecodeXML(r io.Reader) (any, error)

DecodeXML decodes an arbitrary XML from a reader stream.

func Unmarshal

func Unmarshal(contentType string, rawBody []byte) (any, error)

Unmarshal decodes data bytes by content type to arbitrary value.

func UnmarshalJSON

func UnmarshalJSON(b []byte) (any, error)

UnmarshalJSON unmarshals an arbitrary JSON from bytes.

Types

type DataURI

type DataURI struct {
	MediaType  string
	Parameters map[string]string
	Data       []byte
}

DataURI represents the Data URI scheme

func DecodeDataURI

func DecodeDataURI(input string) (*DataURI, error)

DecodeDataURI decodes data URI scheme data:[<media type>][;<key>=<value>][;<extension>],<data>

type DataURIEncoding

type DataURIEncoding uint8

DataURIEncoding represents a encoding num for the data URI.

const (
	// DataUriASCII represents the ascii encoding for the data URI.
	DataUriASCII DataURIEncoding = iota
	// DataURIBase64 represents the base64 encoding enum for the data URI.
	DataURIBase64
)

Jump to

Keyboard shortcuts

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