Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace direct usage of http.DefaultClient in providers and oauth2 calls #87

Merged
merged 2 commits into from
Jan 17, 2017

Conversation

felixLam
Copy link
Contributor

@felixLam felixLam commented Jun 24, 2016

Some providers already used a custom httpClient. This brings the Client field to all providers and uses a fallback method to provide the http.DefaultClient if no client is set.

This also uses the custom httpClient for the oauth2 calls via the context.

The change should allow better inversion of control during unit tests by providing a custom client.

I also ran go format on some files to clean up the import statements.

@felixLam felixLam changed the title Replace direct usage of http.DefaultClient in providers Replace direct usage of http.DefaultClient in providers and oauth2 calls Jun 24, 2016
@markbates
Copy link
Owner

Why not have the Provider interface have a Client() *http.Client function as part of the definition. I feel like that would be the better abstraction.

@felixLam
Copy link
Contributor Author

felixLam commented Jun 24, 2016

I thought so too, but you would still need a field for each provider in order to let you set it externally. The Client field was also already available in some providers. The current implementation requires less code duplication unless I am missing something.

@felixLam
Copy link
Contributor Author

felixLam commented Jul 1, 2016

@markbates Did you have time to look at this PR again? If you have any suggestions I am more than happy to implement them.

@markbates
Copy link
Owner

I'm sorry, I haven't. I'm traveling through Italy right now with my family, so I don't have the time nor the Internet to really investigate. I plan on checking this out when I get to gopher con the end of next week.

@felixLam
Copy link
Contributor Author

felixLam commented Jul 1, 2016

Enjoy your holidays 🇮🇹 and make sure to watch the match with the locals tomorrow ⚽

@felixLam
Copy link
Contributor Author

felixLam commented Aug 5, 2016

Hi @markbates any news on this PR?

@felixLam
Copy link
Contributor Author

@markbates any news on this PR? Is it worthwhile updating it to resolve conflicts?

@willemvd
Copy link
Collaborator

@markbates This would really help us out in Gitea to set custom fields in the Client!
Do you have any plans (and when) to implement these?

@felixLam
Copy link
Contributor Author

@willemvd it is implemented on our branch in this PR. If you care and plan on using it I can rebase it on the current master. Since @markbates has gone radio silent here, I haven't looked into it.

@willemvd
Copy link
Collaborator

@felixLam since @markbates is actually doing stuff on the master (last time 2 days ago) I hope he will respond on this, but a rebase is always welcome!

willemvd added a commit to willemvd/gitea that referenced this pull request Jan 17, 2017
# Conflicts:
#	providers/amazon/amazon.go
#	providers/cloudfoundry/session.go
#	providers/github/github.go
#	providers/gitlab/gitlab.go
#	providers/influxcloud/influxcloud.go
#	providers/influxcloud/session.go
#	providers/instagram/instagram.go
@felixLam
Copy link
Contributor Author

@willemvd I merged master into this PR (didn't do a rebase as we have our own branch on top of this PR). Let me know if this works.

@willemvd
Copy link
Collaborator

@felixLam found out that the new introduced auth0 provider is not updated with the new Provider.Client field

@felixLam
Copy link
Contributor Author

Weird that this is not raised by the CI. I ran the test locally and they passed, can you let me know what command you used that failed?

@felixLam
Copy link
Contributor Author

Simply go build ?

@willemvd
Copy link
Collaborator

I just looked at the code and saw that it was missing (think also in the session.go) 😄
https://github.com/iosphere/goth/blob/feature/httpClient/providers/auth0/auth0.go#L23-L27

@markbates markbates merged commit 2b38cff into markbates:master Jan 17, 2017
@willemvd
Copy link
Collaborator

@markbates Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants