diff --git a/client.go b/client.go index 36bb4f3..12e498b 100644 --- a/client.go +++ b/client.go @@ -66,7 +66,7 @@ func (c *Client) Request(method string, url string, args ...any) *Request { headers: http.Header{}, } - r.SetEncoder(c.config.Encoder) + r.SetEncoder(JsonEncoder) return r } diff --git a/codec.go b/codec.go index a8f1aae..a6ca667 100644 --- a/codec.go +++ b/codec.go @@ -87,6 +87,7 @@ func FormDecode(r io.Reader, v any) error { var buffer = internal.GetBuffer() var p = buffer.Bytes()[:internal.BufferSize] _, _ = io.CopyBuffer(builder, r, p) + internal.PutBuffer(buffer) result, err := url.ParseQuery(builder.String()) if err != nil { return errors.WithStack(err) diff --git a/config.go b/config.go index 7514339..3122615 100644 --- a/config.go +++ b/config.go @@ -49,7 +49,6 @@ type ( BeforeFunc BeforeFunc // 请求前中间件 AfterFunc AfterFunc // 请求后中间件 HTTPClient *http.Client // HTTP客户端 - Encoder Encoder // 编码器 } Option func(c *config) @@ -90,10 +89,6 @@ func withInitialize() Option { c.AfterFunc = defaultAfterFunc } - if c.Encoder == nil { - c.Encoder = JsonEncoder - } - if c.HTTPClient == nil { c.HTTPClient = &http.Client{ Timeout: defaultTimeout, diff --git a/contrib/yaml/codec.go b/contrib/yaml/codec.go index 2b08b1f..8e71553 100644 --- a/contrib/yaml/codec.go +++ b/contrib/yaml/codec.go @@ -31,7 +31,5 @@ func (c encoder) ContentType() string { } func Decode(r io.Reader, v any) error { - return errors.WithStack( - yaml.NewDecoder(r).Decode(v), - ) + return errors.WithStack(yaml.NewDecoder(r).Decode(v)) }