Skip to content

Commit

Permalink
update xhttp client
Browse files Browse the repository at this point in the history
  • Loading branch information
iGoogle-ink committed Nov 2, 2023
1 parent 750d9d1 commit acdb38d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/xhttp/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const (
DELETE = "DELETE"
PATCH = "PATCH"

ResTypeJSON = "application/json"
ResTypeXML = "application/xml"
ResTypeJSON = "json"
ResTypeXML = "xml"

TypeJSON = "json"
TypeXML = "xml"
Expand All @@ -25,7 +25,7 @@ var (
}

_ResTypeMap = map[string]string{
ResTypeJSON: "json",
ResTypeXML: "xml",
ResTypeJSON: "application/json",
ResTypeXML: "application/xml",
}
)
4 changes: 2 additions & 2 deletions pkg/xhttp/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ func (r *Request) EndStruct(ctx context.Context, v any) (res *http.Response, err
}

switch r.responseType {
case string(TypeJSON):
case ResTypeJSON:
err = json.Unmarshal(bs, &v)
if err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s, %+v):%w", string(bs), v, err)
}
return res, nil
case string(TypeXML):
case ResTypeXML:
err = xml.Unmarshal(bs, &v)
if err != nil {
return nil, fmt.Errorf("xml.Unmarshal(%s, %+v):%w", string(bs), v, err)
Expand Down

0 comments on commit acdb38d

Please sign in to comment.