amimof / huego

An extensive Philips Hue client library for Go with an emphasis on simplicity
MIT License
250 stars 36 forks source link

Add custom http.Client support. #53

Closed yunginnanet closed 2 years ago

yunginnanet commented 2 years ago

- 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
codecov-commenter commented 2 years ago

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%) :arrow_up:

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 commented 2 years ago

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