Add pluggable codec support
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type options struct {
|
||||
codecs map[string]CodecFunc
|
||||
broker broker.Broker
|
||||
registry registry.Registry
|
||||
transport transport.Transport
|
||||
@@ -19,7 +20,9 @@ type options struct {
|
||||
}
|
||||
|
||||
func newOptions(opt ...Option) options {
|
||||
var opts options
|
||||
opts := options{
|
||||
codecs: make(map[string]CodecFunc),
|
||||
}
|
||||
|
||||
for _, o := range opt {
|
||||
o(&opts)
|
||||
@@ -116,6 +119,12 @@ func Broker(b broker.Broker) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func Codec(contentType string, cf CodecFunc) Option {
|
||||
return func(o *options) {
|
||||
o.codecs[contentType] = cf
|
||||
}
|
||||
}
|
||||
|
||||
func Registry(r registry.Registry) Option {
|
||||
return func(o *options) {
|
||||
o.registry = r
|
||||
|
Reference in New Issue
Block a user