Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit b327149

Browse files
committed
fix: remove not need mime type
1 parent 3988bf8 commit b327149

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

encoding.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ import (
1313
"github.com/things-go/encoding/codec"
1414
"github.com/things-go/encoding/form"
1515
"github.com/things-go/encoding/jsonpb"
16-
"github.com/things-go/encoding/msgpack"
1716
"github.com/things-go/encoding/proto"
18-
"github.com/things-go/encoding/toml"
19-
"github.com/things-go/encoding/xml"
20-
"github.com/things-go/encoding/yaml"
2117
)
2218

2319
const defaultMemory = 32 << 20
@@ -60,6 +56,24 @@ type Encoding struct {
6056
}
6157

6258
// New encoding with default Marshalers
59+
// Default:
60+
//
61+
// MIMEPOSTForm: form.Codec
62+
// MIMEMultipartPOSTForm: form.MultipartCodec
63+
// MIMEJSON: jsonpb.Codec
64+
// MIMEPROTOBUF: proto.Codec
65+
// mimeQuery: form.QueryCodec
66+
// mimeUri: form.UriCodec
67+
// mimeWildcard: HTTPBodyCodec
68+
//
69+
// you can manually register your custom Marshaler.
70+
//
71+
// MIMEXML: xml.Codec
72+
// MIMEXML2: xml.Codec
73+
// MIMEMSGPACK: msgpack.Codec
74+
// MIMEMSGPACK2: msgpack.Codec
75+
// MIMEYAML: yaml.Codec
76+
// SMIMETOML: toml.Codec
6377
func New() *Encoding {
6478
return &Encoding{
6579
mimeMap: map[string]codec.Marshaler{
@@ -74,13 +88,7 @@ func New() *Encoding {
7488
DiscardUnknown: true,
7589
},
7690
},
77-
MIMEXML: &xml.Codec{},
78-
MIMEXML2: &xml.Codec{},
7991
MIMEPROTOBUF: &proto.Codec{},
80-
MIMEMSGPACK: &msgpack.Codec{},
81-
MIMEMSGPACK2: &msgpack.Codec{},
82-
MIMEYAML: &yaml.Codec{},
83-
MIMETOML: &toml.Codec{},
8492
},
8593
mimeQuery: &form.QueryCodec{Codec: form.New("json")},
8694
mimeUri: &form.UriCodec{Codec: form.New("json")},

encoding_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
"github.com/things-go/encoding/json"
2323
"github.com/things-go/encoding/msgpack"
2424
"github.com/things-go/encoding/testdata/examplepb"
25+
"github.com/things-go/encoding/toml"
26+
"github.com/things-go/encoding/xml"
27+
"github.com/things-go/encoding/yaml"
2528
)
2629

2730
var marshalers = []dummyMarshaler{0, 1}
@@ -211,6 +214,12 @@ var protoMessage = &examplepb.ABitOfEverything{
211214

212215
func Test_Encoding_Bind(t *testing.T) {
213216
registry := New()
217+
_ = registry.Register(MIMEXML, &xml.Codec{})
218+
_ = registry.Register(MIMEXML2, &xml.Codec{})
219+
_ = registry.Register(MIMEMSGPACK, &msgpack.Codec{})
220+
_ = registry.Register(MIMEMSGPACK2, &msgpack.Codec{})
221+
_ = registry.Register(MIMEYAML, &yaml.Codec{})
222+
_ = registry.Register(MIMETOML, &toml.Codec{})
214223
tests := []struct {
215224
name string
216225
genReq func() (*http.Request, error)

0 commit comments

Comments
 (0)