diff --git a/encoding/xml/xml_test.go b/encoding/xml/xml_test.go new file mode 100644 index 0000000..866d999 --- /dev/null +++ b/encoding/xml/xml_test.go @@ -0,0 +1,19 @@ +package xml + +import ( + "fmt" + "testing" +) + +type Map struct { + Use int + A string +} + +func TestEncode(t *testing.T) { + c := codec{} + fmt.Println(c.Marshal(Map{ + Use: 11, + A: "xxx", + })) +} diff --git a/transport/http/codec.go b/transport/http/codec.go index cf65f86..a90a702 100644 --- a/transport/http/codec.go +++ b/transport/http/codec.go @@ -57,7 +57,6 @@ func DefaultRequestDecoder(r *http.Request, v any) error { return nil } func DefaultResponseEncoder(w http.ResponseWriter, r *http.Request, v any) error { - fmt.Println("DefaultResponseEncoder") if v == nil { return nil } @@ -76,12 +75,8 @@ func DefaultResponseEncoder(w http.ResponseWriter, r *http.Request, v any) error return err } func DefaultErrorEncoder(w http.ResponseWriter, r *http.Request, err error) { - fmt.Println("DefaultErrorEncoder") se := errors.FromError(err) codec, _ := CodeForRequest(r, "Accept") - codec = encoding.GetCodec("xml") - fmt.Println(codec.Name()) - fmt.Printf("%+v\n", se) body, err := codec.Marshal(se) if err != nil { w.WriteHeader(http.StatusInternalServerError)