rpc/encode/selector.go

26 lines
650 B
Go
Raw Normal View History

2017-10-26 07:21:35 +00:00
package encode
import "io"
// EncoderSelector 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 EncoderSelector interface {
2017-10-31 09:25:44 +00:00
SelectByReader(r io.Reader) Encoder
SelectByWriter(w io.Writer) Encoder
2017-10-26 07:21:35 +00:00
}
type encoderSelector struct {
}
2017-10-31 09:25:44 +00:00
func (_ *encoderSelector) SelectByReader(_ io.Reader) Encoder {
return DefaultEncoder
}
func (_ *encoderSelector) SelectByWriter(_ io.Writer) Encoder {
2017-10-26 07:21:35 +00:00
return DefaultEncoder
}
var DefaultEncoderSelector = &encoderSelector{}