Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8242955

Browse files
author
Openset
committed
Update: client
1 parent 7e16b71 commit 8242955

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

‎internal/client/client.go‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@ func init() {
2525
}
2626

2727
func Get(url string) []byte {
28-
resp, err := http.Get(url)
29-
base.CheckErr(err)
30-
defer resp.Body.Close()
31-
body, err := ioutil.ReadAll(resp.Body)
32-
base.CheckErr(err)
33-
return body
28+
if resp, err := http.Get(url); err == nil {
29+
defer resp.Body.Close()
30+
body, err := ioutil.ReadAll(resp.Body)
31+
base.CheckErr(err)
32+
return body
33+
}
34+
return nil
3435
}
3536

3637
func PostJson(url, jsonStr string) []byte {
37-
resp, err := http.Post(url, "application/json", strings.NewReader(jsonStr))
38-
base.CheckErr(err)
39-
defer resp.Body.Close()
40-
body, err := ioutil.ReadAll(resp.Body)
41-
base.CheckErr(err)
42-
return body
38+
if resp, err := http.Post(url, "application/json", strings.NewReader(jsonStr)); err == nil {
39+
defer resp.Body.Close()
40+
body, err := ioutil.ReadAll(resp.Body)
41+
base.CheckErr(err)
42+
return body
43+
}
44+
return nil
4345
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /