encoders

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package encoders is a set of encoders to be used with Jenny

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncoderNotFound = errors.New("unsupported media response in Accept")
	JSONEncoder        = func(w io.Writer) Encoder {
		return json.NewEncoder(w)
	}
	XMLEncoder = func(w io.Writer) Encoder {
		return xml.NewEncoder(w)
	}
	TextEncoder = func(w io.Writer) Encoder {
		return &plainTextEncoder{w: w}
	}
	FormEncoder = func(w io.Writer) Encoder {
		return &formEncoder{w: w}
	}
	ByteEncoder = func(w io.Writer) Encoder {
		return &byteEncoder{w: w}
	}
)
View Source
var ErrByteEncoderNotSupported = errors.New("unsupported interface for byte encoder")

Functions

func AcceptsMustMatch

func AcceptsMustMatch(accepts []mime.Type) endpoint.Middleware

AcceptsMustMatch checks if the mimetypes for the incoming request <re correct.

func Register

func Register(s mime.Type, n NewEncoderFunc)

Register takes a mimeType and reginerters a NewEncoderFunc with

Types

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder returns encoder that wraps around

type NewEncoderFunc

type NewEncoderFunc func(io.Writer) Encoder

func ResponseEncoder

func ResponseEncoder(ctx context.Context, accepts []mime.Type) (newEnc NewEncoderFunc, mimeType mime.Type, err error)

ResponseEncoder returns an encoder and it's corresponding minmetype

Jump to

Keyboard shortcuts

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