Skip to content

Commit c32bfac

Browse files
committed
feat: make json as the default content type.
1 parent 54fbbf1 commit c32bfac

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

body.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ func (cli *Client) getRequestBody(opt RequestOptions) (io.Reader, error) {
1616
contentType := getContentType(opt.ContentType)
1717

1818
switch contentType {
19-
case "application/json", "": // Default JSON
19+
default:
2020
data, err := json.Marshal(body)
2121
if err != nil {
2222
return nil, err
2323
}
2424

2525
return bytes.NewReader(data), nil
26-
default:
27-
return nil, ErrUnsupportedContentType
2826
}
2927
}

wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func ToObject[T any](resp *http.Response, err error) (*T, *http.Response, error)
2020

2121
contentType := resp.Header.Get("Content-Type")
2222
switch getContentType(contentType) {
23-
case "application/json":
23+
default:
2424
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
2525
return nil, resp, err
2626
}

0 commit comments

Comments
 (0)