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 c317bcf

Browse files
iwanbkunknwon
authored andcommitted
Split Client.getResponse to Client.doRequest & Client.getResponse. (#44)
There is some API that give empty response and we only need to check HTTP status code. example : https://developer.github.com/v3/issues/assignees/#check-assignee But there is no way to do this in current code because getResponse will parse the response body and not returning HTTP status code. Client.doRequest makes it possible to do this.
1 parent c52f7ee commit c317bcf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎gogs.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (c *Client) SetHTTPClient(client *http.Client) {
3838
c.client = client
3939
}
4040

41-
func (c *Client) getResponse(method, path string, header http.Header, body io.Reader) ([]byte, error) {
41+
func (c *Client) doRequest(method, path string, header http.Header, body io.Reader) (*http.Response, error) {
4242
req, err := http.NewRequest(method, c.url+"/api/v1"+path, body)
4343
if err != nil {
4444
return nil, err
@@ -48,7 +48,11 @@ func (c *Client) getResponse(method, path string, header http.Header, body io.Re
4848
req.Header[k] = v
4949
}
5050

51-
resp, err := c.client.Do(req)
51+
return c.client.Do(req)
52+
}
53+
54+
func (c *Client) getResponse(method, path string, header http.Header, body io.Reader) ([]byte, error) {
55+
resp, err := c.doRequest(method, path, header, body)
5256
if err != nil {
5357
return nil, err
5458
}

0 commit comments

Comments
(0)

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