Skip to content

Commit 6172b25

Browse files
author
jianggb
committed
fix: remove default proto codec
1 parent 9567501 commit 6172b25

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

encoding.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/things-go/encoding/codec"
1212
"github.com/things-go/encoding/form"
1313
"github.com/things-go/encoding/json"
14-
"github.com/things-go/encoding/proto"
1514
)
1615

1716
const defaultMemory = 32 << 20
@@ -59,26 +58,25 @@ type Encoding struct {
5958
// MIMEPOSTForm: form.Codec
6059
// MIMEMultipartPOSTForm: form.MultipartCodec
6160
// MIMEJSON: json.Codec
62-
// MIMEPROTOBUF: proto.Codec
6361
// mimeQuery: form.QueryCodec
6462
// mimeUri: form.UriCodec
6563
// mimeWildcard: json.Codec
6664
//
6765
// you can manually register your custom Marshaler.
6866
//
67+
// MIMEPROTOBUF: proto.Codec
6968
// MIMEXML: xml.Codec
7069
// MIMEXML2: xml.Codec
7170
// MIMEMSGPACK: msgpack.Codec
7271
// MIMEMSGPACK2: msgpack.Codec
7372
// MIMEYAML: yaml.Codec
74-
// SMIMETOML: toml.Codec
73+
// MIMETOML: toml.Codec
7574
func New() *Encoding {
7675
return &Encoding{
7776
mimeMap: map[string]codec.Marshaler{
7877
MIMEPOSTForm: form.New("json"),
7978
MIMEMultipartPOSTForm: &form.MultipartCodec{Codec: form.New("json")},
8079
MIMEJSON: &json.Codec{UseNumber: true, DisallowUnknownFields: true},
81-
MIMEPROTOBUF: &proto.Codec{},
8280
},
8381
mimeQuery: &form.QueryCodec{Codec: form.New("json")},
8482
mimeUri: &form.UriCodec{Codec: form.New("json")},

encoding_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ func Test_Encoding_Register(t *testing.T) {
4545
})
4646
t.Run("remove MIME type", func(t *testing.T) {
4747
registry := New()
48+
err := registry.Register(MIMEPROTOBUF, &pro.Codec{})
49+
require.NoError(t, err)
4850

4951
got := registry.Get(MIMEPROTOBUF)
5052
_, ok := got.(*pro.Codec)
5153
require.True(t, ok, "should be got MIME proto marshaler")
5254

53-
err := registry.Delete(MIMEPROTOBUF)
55+
err = registry.Delete(MIMEPROTOBUF)
5456
require.NoError(t, err)
5557

5658
got = registry.Get(MIMEPROTOBUF)
@@ -215,6 +217,7 @@ var protoMessage = &examplepb.ABitOfEverything{
215217

216218
func Test_Encoding_Bind(t *testing.T) {
217219
registry := New()
220+
_ = registry.Register(MIMEPROTOBUF, &pro.Codec{})
218221
_ = registry.Register(MIMEXML, &xml.Codec{})
219222
_ = registry.Register(MIMEXML2, &xml.Codec{})
220223
_ = registry.Register(MIMEMSGPACK, &msgpack.Codec{})

httpbody_proto.go renamed to httpbody/httpbody_proto.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package encoding
1+
package httpbody
22

33
import (
44
"google.golang.org/genproto/googleapis/api/httpbody"

httpbody_proto_test.go renamed to httpbody/httpbody_proto_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package encoding
1+
package httpbody
22

33
import (
44
"bytes"

0 commit comments

Comments
 (0)