Skip to content

Conversation

@itsibitzi
Copy link
Contributor

This is helpful because there are times you need to set the http client when in direct mode. E.g. you want to preload a load of default headers.

Changed the ClientBuilder::new to no longer take the http client, they can use the method if they need it. This is a minor breaking change but should be easy to port.

Uses Option<Client> in the build because building a HTTP client is non-trivial so it's nicer to not do it twice in the case where you want to use a custom client.

@itsibitzi itsibitzi requested a review from a team as a code owner October 13, 2025 10:28
Copilot AI review requested due to automatic review settings October 13, 2025 10:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the ClientBuilder to move HTTP client configuration into a separate method, making it optional in the constructor. This provides better flexibility for setting up custom HTTP clients with default headers when using direct mode.

  • Moved HTTP client parameter from ClientBuilder::new() to a separate with_http_client() method
  • Changed the internal http_client field to Option<reqwest::Client> to defer client creation
  • Updated the build() method to create a default client when none is provided

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

self
}

/// Set the HTTP client. Without this a default HTTP client is used.
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'it's' to 'its' in the commit title. The word 'its' is possessive and doesn't need an apostrophe.

Copilot uses AI. Check for mistakes.
This is helpful because there are times you need to set the http client 
when in direct mode. E.g. you want to preload a load of default headers.
@itsibitzi itsibitzi force-pushed the itsibitzi/20251013-builder-http-client branch from ebfc2fb to 2ace17b Compare October 13, 2025 10:29
Copy link
Contributor

@aneubeck aneubeck left a comment

Choose a reason for hiding this comment

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

👍

@itsibitzi itsibitzi added this pull request to the merge queue Oct 13, 2025
@itsibitzi itsibitzi removed this pull request from the merge queue due to a manual request Oct 13, 2025
@itsibitzi itsibitzi changed the title Move http client on twirp client build to it's own method. Oct 13, 2025
@itsibitzi itsibitzi added this pull request to the merge queue Oct 13, 2025
Merged via the queue into main with commit b51ab3a Oct 13, 2025
5 checks passed
@itsibitzi itsibitzi deleted the itsibitzi/20251013-builder-http-client branch October 13, 2025 10:38
@github-actions github-actions bot mentioned this pull request Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants