rpc/codec/selector.go

26 lines
623 B
Go
Raw Normal View History

2017-11-26 10:15:51 +00:00
package codec
import "io"
// CodecSelector interface provides a way to select encoder using the http
// request. Typically people can use this to check HEADER of the request and
// figure out client capabilities.
// Eg. "Accept-Encoding" tells about supported compressions.
type CodecSelector interface {
SelectByReader(r io.Reader) Codec
SelectByWriter(w io.Writer) Codec
}
type codecSelector struct {
}
func (_ *codecSelector) SelectByReader(_ io.Reader) Codec {
return DefaultCodec
}
func (_ *codecSelector) SelectByWriter(_ io.Writer) Codec {
return DefaultCodec
}
var DefaultCodecSelector = &codecSelector{}