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

Allows to set custom properties on a teams client #927

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

firefart
Copy link
Contributor

@firefart firefart commented Jan 8, 2025

Description

These changes allow so set the following parameters on the teams client:

  • A custom Proxy URL (the plugin normally uses the ENV variables, but now you can also set it directly)
  • A custom user agent for all outgoing requests to Teams
  • A custom HTTP Client if you want to tweak even more properties

The methods are all accessible on the TeamsClient https://github.com/atc0005/go-teams-notify/blob/master/send.go

Motivation and Context

Setting a Proxy on outgoing requests without using env variables

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 0% with 89 lines in your changes missing coverage. Please review.

Project coverage is 28.66%. Comparing base (8efdc15) to head (9f71118).
Report is 86 commits behind head on main.

Files with missing lines Patch % Lines
service/msteams/mock_teams_client.go 0.00% 78 Missing ⚠️
service/msteams/ms_teams.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #927       +/-   ##
===========================================
- Coverage   74.10%   28.66%   -45.45%     
===========================================
  Files          44       61       +17     
  Lines        1572     2735     +1163     
===========================================
- Hits         1165      784      -381     
- Misses        307     1830     +1523     
- Partials      100      121       +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nikoksr
Copy link
Owner

nikoksr commented Jan 12, 2025

Hi @firefart, thank you for the PR! Just a quick question, I'm not able to try this out rn, but wouldn't it be possible to set the proxy by using the SetHTTPClient() method you provided?

client := http.DefaultClient
client.Transport = &http.Transport{Proxy: http.ProxyURL(url)}

teamsSvc.SetHTTPClient(client)

Or does SetProxy() serve another purpose besides comfort that I'm missing? Because while I do enjoy the comfort this brings, it also leads to a commitment for us to add setter functions per field of mutable state. While v2 of the library is on the horizon, I'd still like to strike a balance between control and minimalism when it comes to the API of v1. SetHTTPClient() gives full control over the HTTP client while having minimal impact on the API's verbosity.

Let me know your thoughts on this, totally possible I'm just missing something. Cheers :)

@firefart
Copy link
Contributor Author

Hi,
jeah I just wanted to set the proxy by hand and it's doable with the SetHTTPClient only too. I just exposed some methods that might be interesting to some users, but I'm also happy to just include SetHTTPClient

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

Successfully merging this pull request may close these issues.

2 participants