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

Add custom http.Client support. #53

Merged
merged 6 commits into from
Feb 27, 2022
Merged

Add custom http.Client support. #53

merged 6 commits into from
Feb 27, 2022

Conversation

yunginnanet
Copy link
Contributor

@yunginnanet yunginnanet commented Feb 16, 2022

- What I did
Added the ability to use a custom http.Client when interacting with bridges. My particular use-case comes from all of my lighting being segmented off, this allows for me to use my router as a middle-man via an SSH tunnel. However, I feel there are many, many use-cases.

- How I did it
I created a new function similar to New called NewCustom, it is just about the same except for it allows you to pass in your own http.Client. I then refactored all of the unexported http functions (get, put etc) to be methods of Bridge. This allows them to function using http.DefaultClient during normal operations, but with the custom http.Client otherwise.

- How to verify it
I've not only verified that this works for my use-case, but frankly making the testcases work (I didn't realize how httpmock had worked until today) was more work than the modification itself. So I think CI does a pretty good job of verification :)

- Description for the CHANGELOG

## 1.0.3
* Added ability to use a custom http.Client

Copy link
Owner

@amimof amimof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunginnanet Thanks for the contribution 👏 Please have a look at my suggestions

CHANGELOG.md Outdated Show resolved Hide resolved
huego.go Outdated Show resolved Hide resolved
huego.go Outdated Show resolved Hide resolved
bridge_test.go Outdated Show resolved Hide resolved
@yunginnanet yunginnanet requested a review from amimof February 26, 2022 12:38
@codecov-commenter
Copy link

codecov-commenter commented Feb 26, 2022

Codecov Report

Merging #53 (8683a44) into master (76fe39c) will increase coverage by 0.11%.
The diff coverage is 96.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
+ Coverage   73.42%   73.53%   +0.11%     
==========================================
  Files           5        5              
  Lines        1430     1436       +6     
==========================================
+ Hits         1050     1056       +6     
  Misses        210      210              
  Partials      170      170              
Impacted Files Coverage Δ
bridge.go 63.82% <96.00%> (ø)
huego.go 78.62% <100.00%> (+1.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76fe39c...8683a44. Read the comment docs.

@amimof amimof merged commit 5668ae6 into amimof:master Feb 27, 2022
@amimof
Copy link
Owner

amimof commented Feb 27, 2022

@yunginnanet Looks good 👍 Also, I’ve started working on version 2 with Bridge V2 API support. Would you be interested in helping out? #52

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