Make http requests with context #417

Merged
6543 merged 9 commits from 6543/go-sdk:with-ctx into master 2020-09-15 16:21:49 +00:00
Owner

close #397

close #397
6543 added this to the v0.13.0 milestone 2020-09-12 21:35:10 +00:00
6543 added the
kind/feature
status/needs-reviews
labels 2020-09-12 21:35:10 +00:00
6543 added 1 commit 2020-09-12 21:35:13 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
55834e66c6
optional exec http requests with context
6543 added 1 commit 2020-09-14 02:42:19 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
fcf6c1d7b0
Merge branch 'master' into with-ctx
lunny approved these changes 2020-09-14 02:53:29 +00:00
Dismissed
jolheiser reviewed 2020-09-14 03:36:51 +00:00
Dismissed
jolheiser left a comment
Owner

If we are going to add contexts, we should at least use context.Background() if the user doesn't set their own. That way there's less nil-checking and fewer footguns.

This might also be a good opportunity to add the functional options to the NewClient func.

If we are going to add contexts, we should at least use `context.Background()` if the user doesn't set their own. That way there's less nil-checking and fewer footguns. This might also be a good opportunity to add the functional options to the `NewClient` func.
Owner

What's the minimum version of go we accept for the SDK?

RequestWithContext is go 1.13+

What's the minimum version of go we accept for the SDK? RequestWithContext is go 1.13+
6543 added
status/wip
and removed
status/needs-reviews
labels 2020-09-14 22:42:57 +00:00
Author
Owner

What's the minimum version of go we accept for the SDK?

with this it is v1.13 or is there a reason to support older?

> What's the minimum version of go we accept for the SDK? with this it is v1.13 or is there a reason to support older?
jolheiser requested changes 2020-09-15 14:16:39 +00:00
Dismissed
gitea/client.go Outdated
@ -84,0 +92,4 @@
err error
)
if c.ctx == nil {
req, err = http.NewRequest(method, c.url+path, body)
Owner

At the very least if we are moving towards contexts we should use context.Background() rather than these nil-checks.

At the very least if we are moving towards contexts we should use `context.Background()` rather than these nil-checks.
6543 changed title from Make http requests with context (optional) to Make http requests with context 2020-09-15 14:51:35 +00:00
6543 added 4 commits 2020-09-15 14:51:43 +00:00
6543 added 1 commit 2020-09-15 14:56:14 +00:00
Some checks failed
continuous-integration/drone/pr Build is failing
9062e028a0
md format
jolheiser requested changes 2020-09-15 15:02:05 +00:00
Dismissed
jolheiser left a comment
Owner

A few nits.

Only other nit than those would be personal preference. I like options funcs to start with With, but Set somewhat conveys the same thing.

A few nits. Only other nit than those would be personal preference. I like options funcs to start with `With`, but `Set` somewhat conveys the same thing.
gitea/client.go Outdated
@ -49,3 +49,1 @@
url: strings.TrimSuffix(url, "/"),
accessToken: token,
client: &http.Client{},
func NewClient(url string, options ...func(*Client) error) (*Client, error) {
Owner

It doesn't look like any of the functional optional actually return an error?

I think this might be an attempt at fixing a future problem (which is fine), but imo setting an option shouldn't be able to inherently throw an error.

It doesn't look like any of the functional optional actually return an error? I think this might be an attempt at fixing a future problem (which is fine), but imo setting an option shouldn't be able to inherently throw an error.
Author
Owner

this is for future problems ... do we realy have to remove it?

this is for future problems ... do we realy have to remove it?
gitea/client.go Outdated
@ -53,3 +61,4 @@
}
// NewClientWithHTTP creates an API client with a custom http client
// Deprecated use CustomHTTPClient option
Owner

I don't see a CustomHTTPClient func

I don't see a `CustomHTTPClient` func
6543 added 1 commit 2020-09-15 15:15:23 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
832b636378
fix test & code comment
6543 added 1 commit 2020-09-15 15:23:25 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing
9ecb1edf9f
Functional Options dont have a reason for an error (at the moment)
Author
Owner

@jolheiser done

@jolheiser done
6543 added
status/needs-reviews
and removed
status/wip
labels 2020-09-15 15:35:19 +00:00
jolheiser approved these changes 2020-09-15 15:57:20 +00:00
Dismissed
6543 removed the
status/needs-reviews
label 2020-09-15 16:20:56 +00:00
6543 merged commit 51d1bddc8a into master 2020-09-15 16:21:44 +00:00
6543 deleted branch with-ctx 2020-09-15 16:21:53 +00:00
Sign in to join this conversation.
No description provided.