diff options
author | Igor Drozdov <idrozdov@gitlab.com> | 2019-05-22 15:50:40 +0300 |
---|---|---|
committer | Igor Drozdov <idrozdov@gitlab.com> | 2019-05-31 11:32:27 +0300 |
commit | a701af0378cc9a53170f60b95df8cfdcbca04ea7 (patch) | |
tree | 9c57bf733e572314e3fbba29b6443805bb9afbca /go/internal/gitlabnet/client.go | |
parent | c86081506c706c6230c247a2391f35d35130ca94 (diff) | |
download | gitlab-shell-id-git-receive-pack.tar.gz |
Go implementation for git-receive-packid-git-receive-pack
Diffstat (limited to 'go/internal/gitlabnet/client.go')
-rw-r--r-- | go/internal/gitlabnet/client.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/go/internal/gitlabnet/client.go b/go/internal/gitlabnet/client.go index 86add04..dacb1d6 100644 --- a/go/internal/gitlabnet/client.go +++ b/go/internal/gitlabnet/client.go @@ -53,8 +53,6 @@ func normalizePath(path string) string { } func newRequest(method, host, path string, data interface{}) (*http.Request, error) { - path = normalizePath(path) - var jsonReader io.Reader if data != nil { jsonData, err := json.Marshal(data) @@ -74,7 +72,7 @@ func newRequest(method, host, path string, data interface{}) (*http.Request, err } func parseError(resp *http.Response) error { - if resp.StatusCode >= 200 && resp.StatusCode <= 299 { + if resp.StatusCode >= 200 && resp.StatusCode <= 399 { return nil } defer resp.Body.Close() @@ -89,14 +87,14 @@ func parseError(resp *http.Response) error { } func (c *GitlabClient) Get(path string) (*http.Response, error) { - return c.doRequest("GET", path, nil) + return c.DoRequest(http.MethodGet, normalizePath(path), nil) } func (c *GitlabClient) Post(path string, data interface{}) (*http.Response, error) { - return c.doRequest("POST", path, data) + return c.DoRequest(http.MethodPost, normalizePath(path), data) } -func (c *GitlabClient) doRequest(method, path string, data interface{}) (*http.Response, error) { +func (c *GitlabClient) DoRequest(method, path string, data interface{}) (*http.Response, error) { request, err := newRequest(method, c.host, path, data) if err != nil { return nil, err |