rpc/codec/selector.go
crusader 2286a5021e ing
2017-11-26 19:15:51 +09:00

26 lines
623 B
Go

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{}