@@ -11,14 +11,15 @@ import (
11
11
"strconv"
12
12
"strings"
13
13
14
+ "bytes"
15
+ "io"
16
+ "mime/multipart"
17
+ "os"
18
+
14
19
"golang.org/x/net/context"
15
20
"golang.org/x/oauth2"
16
21
"golang.org/x/oauth2/bitbucket"
17
22
"golang.org/x/oauth2/clientcredentials"
18
- "bytes"
19
- "mime/multipart"
20
- "io"
21
- "os"
22
23
)
23
24
24
25
const DEFAULT_PAGE_LENGTH = 10
@@ -31,7 +32,7 @@ type Client struct {
31
32
Repositories * Repositories
32
33
Pagelen uint64
33
34
34
- HttpClient * http.Client
35
+ HttpClient * http.Client
35
36
}
36
37
37
38
type auth struct {
@@ -130,7 +131,7 @@ func injectClient(a *auth) *Client {
130
131
Diff : & Diff {c : c },
131
132
BranchRestrictions : & BranchRestrictions {c : c },
132
133
Webhooks : & Webhooks {c : c },
133
- Downloads : & Downloads {c : c },
134
+ Downloads : & Downloads {c : c },
134
135
}
135
136
c .Users = & Users {c : c }
136
137
c .User = & User {c : c }
@@ -167,6 +168,9 @@ func (c *Client) execute(method string, urlStr string, text string) (interface{}
167
168
168
169
c .authenticateRequest (req )
169
170
result , err := c .doRequest (req , false )
171
+ if err != nil {
172
+ return nil , err
173
+ }
170
174
171
175
//autopaginate.
172
176
resultMap , isMap := result .(map [string ]interface {})
@@ -221,7 +225,7 @@ func (c *Client) executeFileUpload(method string, urlStr string, filePath string
221
225
222
226
var fw io.Writer
223
227
if fw , err = w .CreateFormFile ("files" , fileName ); err != nil {
224
- return nil , err
228
+ return nil , err
225
229
}
226
230
227
231
if _ , err = io .Copy (fw , fileReader ); err != nil {
@@ -245,7 +249,7 @@ func (c *Client) executeFileUpload(method string, urlStr string, filePath string
245
249
246
250
}
247
251
248
- func (c * Client ) authenticateRequest (req * http.Request ){
252
+ func (c * Client ) authenticateRequest (req * http.Request ) {
249
253
if c .Auth .bearerToken != "" {
250
254
req .Header .Set ("Authorization" , "Bearer " + c .Auth .bearerToken )
251
255
}
@@ -258,8 +262,7 @@ func (c *Client) authenticateRequest(req *http.Request){
258
262
return
259
263
}
260
264
261
-
262
- func (c * Client ) doRequest (req * http.Request , emptyResponse bool ) (interface {}, error ){
265
+ func (c * Client ) doRequest (req * http.Request , emptyResponse bool ) (interface {}, error ) {
263
266
264
267
resp , err := c .HttpClient .Do (req )
265
268
if err != nil {
@@ -295,7 +298,6 @@ func (c *Client) doRequest(req *http.Request, emptyResponse bool) (interface{},
295
298
return result , nil
296
299
}
297
300
298
-
299
301
func (c * Client ) requestUrl (template string , args ... interface {}) string {
300
302
301
303
if len (args ) == 1 && args [0 ] == "" {
0 commit comments