encoding

package
v0.0.0-...-17ece98 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTML MIME type.
	HTML = "text/html"
	// JSON MIME type.
	JSON = "application/json"
	// TEXT MIME type.
	TEXT = "text/plain"
	// XML MIME type.
	XML = "application/xml"
)

Variables

This section is empty.

Functions

func IsSupported

func IsSupported(contentType string) bool

IsSupported returns true if the provided content type is supported by encoder.

func Offers

func Offers() []string

Offers returns supported content types.

Types

type Encoder

type Encoder interface {
	// Encode writes the encoding of the value to the stream.
	Encode(interface{}) error
}

Encoder defines basic behavior of encoders.

type Generic

type Generic interface {
	Encoder

	// ContentType returns a content type of the encoder.
	ContentType() string
}

Generic defines basic behavior of the application encoder.

func NewEncoder

func NewEncoder(stream io.Writer, contentType string) Generic

NewEncoder returns encoder corresponding to the content type. It can raise panic if the content type is not supported. Use IsSupported first to check that.

Jump to

Keyboard shortcuts

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