func (p *Parcel) GetEncoder() Encoder {
	accepts := parseAccept(p.R.Header.Get("Accept"))
	if len(accepts) == 0 {
		if p.R.Method == "POST" || p.R.Method == "PUT" || p.R.Method == "PATCH" {
			mt, _, err := mime.ParseMediaType(p.R.Header.Get("Content-Type"))
			if err == nil {
				accepts = append(accepts, mt)
			}
		}
	}
	for _, a := range accepts {
		accepted := p.factory.encoders[a]
		if accepted != nil {
			return accepted
		}
	}
	if p.factory.defaultEncoder != nil {
		return p.factory.defaultEncoder
	} else {
		return nil
	}
}
GetEncoder will return the encoder that will be used for encoding
based on parcel's content negotiation rules
package parcel
import (
	"errors"
	"mime"
	"net/http"
	"strings"
)
type (
	Candidate interface{}
	Decoder interface {
		Decode(*http.Request, interface{}) error
	}
	Encoder interface {
		Encodes() []string
		ContentType() string
		Encode(http.ResponseWriter, interface{}) error
	}
	Parcel struct {
		RW      http.ResponseWriter
		R       *http.Request
		factory *Factory
	}
	Factory struct {
		defaultEncoder Encoder
		encoders       map[string]Encoder
		decoders       []Decoder
	}
)
var (
	ResponseNotWrittenError = errors.New("Response was not written: No encoder indicated a written response")
)
func NewFactory() *Factory {
	f := new(Factory)
	f.encoders = make(map[string]Encoder)
	f.decoders = make([]Decoder, 0)
	return f
}
func (f *Factory) UseDefaultEncoder(encoder Encoder) {
	f.defaultEncoder = encoder
}
func (f *Factory) UseEncoder(encoder Encoder) {
	for _, encodes := range encoder.Encodes() {
		f.encoders[encodes] = encoder
	}
}
func (f *Factory) UseDecoder(decoder Decoder) {
	f.decoders = append(f.decoders, decoder)
}
func (f *Factory) Use(i interface{}) {
	if decoder, ok := i.(Decoder); ok {
		f.UseDecoder(decoder)
	}
	if encoder, ok := i.(Encoder); ok {
		f.UseEncoder(encoder)
	}
}
func (f *Factory) Parcel(rw http.ResponseWriter, r *http.Request) *Parcel {
	return &Parcel{RW: rw, R: r, factory: f}
}
func (p *Parcel) Encode(code int, c Candidate) error {
	encoder := p.GetEncoder()
	if encoder != nil {
		p.RW.Header().Set("Content-Type", encoder.ContentType())
		p.RW.WriteHeader(code)
		return encoder.Encode(p.RW, c)
	} else {
		return ResponseNotWrittenError
	}
}
func (p *Parcel) Decode(c Candidate) (err error) {
	for _, decoder := range p.factory.decoders {
		if err = decoder.Decode(p.R, c); err != nil {
			return
		}
	}
	return
}