encoding

package
v0.0.0-...-21d6f6e Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownContentType = errors.New("error-no-content-type")
	ErrIncompatibleType   = errors.New("error-incompatible-type")
	ErrBadContentType     = errors.New("err-bad-content-type")
)

Functions

func Check

func Check(c ContentType) bool

func Marshal

func Marshal(t ContentType, writer io.Writer, value interface{}) error

func MarshalJSON

func MarshalJSON(w io.Writer, v interface{}) error

func MarshalProtobuf

func MarshalProtobuf(w io.Writer, any interface{}) error

func MarshalString

func MarshalString(w io.Writer, value interface{}) error

func MarshalYAML

func MarshalYAML(w io.Writer, v interface{}) error

func Unmarshal

func Unmarshal(t ContentType, reader io.Reader, value interface{}) error

func UnmarshalJSON

func UnmarshalJSON(r io.Reader, v interface{}) error

func UnmarshalProtobuf

func UnmarshalProtobuf(r io.Reader, any interface{}) error

func UnmarshalString

func UnmarshalString(r io.Reader, v interface{}) error

func UnmarshalYAML

func UnmarshalYAML(r io.Reader, v interface{}) error

Types

type ContentType

type ContentType string
const (
	ContentTypeDefault  ContentType = ContentType("")
	ContentTypeAny      ContentType = ContentType("*/*")
	ContentTypeJSON     ContentType = ContentType("application/json")
	ContentTypeYAML     ContentType = ContentType("application/yaml")
	ContentTypeProtobuf ContentType = ContentType("application/protobuf")
	ContentTypeHTML     ContentType = ContentType("text/html")
	ContentTypePlain    ContentType = ContentType("text/plain")
)

func ContentTypeFromString

func ContentTypeFromString(t string) (ContentType, error)

Returns the ContentType given the string.

func (ContentType) String

func (this ContentType) String() string

type Duration

type Duration struct {
	time.Duration
}

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (v interface{}, err error)

func (*Duration) String

func (d *Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) (err error)

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

Jump to

Keyboard shortcuts

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