File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ import (
4
4
"sync"
5
5
)
6
6
7
+ const (
8
+ JSONCodecName = "application/json"
9
+ ProtoCodecName = "application/protobuf"
10
+ XMLCodecName = "application/xml"
11
+ )
12
+
7
13
// Codec is an interface that encodes message on pub and decodes it on sub.
8
14
type Codec interface {
9
15
Encoder
@@ -20,9 +26,9 @@ var Register = register{codecs: make(map[string]Codec)}
20
26
21
27
func init () {
22
28
Register .Register ("" , & JSONCodec {})
23
- Register .Register ("application/json" , & JSONCodec {})
24
- Register .Register ("application/xml" , & XMLCodec {})
25
- Register .Register ("application/protobuf" , & ProtobufCodec {})
29
+ Register .Register (JSONCodecName , & JSONCodec {})
30
+ Register .Register (XMLCodecName , & XMLCodec {})
31
+ Register .Register (ProtoCodecName , & ProtobufCodec {})
26
32
}
27
33
28
34
type register struct {
Original file line number Diff line number Diff line change @@ -69,3 +69,9 @@ func PublisherHandlersAmount(n int) PublisherOption {
69
69
}
70
70
}
71
71
}
72
+
73
+ func PublisherContentType (t string ) PublisherOption {
74
+ return func (publisher * Publisher ) {
75
+ publisher .opts .defaultContentType = t
76
+ }
77
+ }
You can’t perform that action at this time.
0 commit comments