Skip to content

feat: Add rest.Catalog Option to provide custom http.RoundTripper - #552

Merged
zeroshade merged 5 commits into
apache:mainfrom
joellubi:custom-transport
Sep 2, 2025
Merged

zeroshade merged 5 commits into
apache:mainfrom
joellubi:custom-transport

Conversation

@joellubi

Copy link
Copy Markdown
Member

fixes: #551

Enables customization of the catalog's http.Client.Transport via the http.RoundTripper interface. Technically certain existing options such as options.tlsConfig could be achieved by specifying a options.transport with that config set, but the option is left in for compatibility.

Comment thread catalog/rest/rest.go Outdated
type sessionTransport struct {
http.Transport

transport http.RoundTripper

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the benefit to doing this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This allows alternate transports to be used, not just the builtin http.Transport implementation. In practice any real http.RoundTripper is going to wrap http.Transport at some level, but it opens up the ability to pass in a client with "middleware" such as instrumentation, added auth, etc without needing to handle it in this library's implementation. I added some context for why it's helpful in the linked issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can also embed the interface instead of making it into an unexported field, similar to how it was before. That change wasn't necessary. I just pushed that up.

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM just one last thing

Comment thread catalog/rest/options.go
}
}

func WithCustomTransport(transport http.RoundTripper) Option {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Last nit: needs a docstring comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a docstring calling out the potential for this option to shadow WithTLSConfig, but also added a check to specifically report that condition and a test for it. Let me know what you think.

@joellubi
joellubi requested a review from zeroshade September 2, 2025 19:48
@zeroshade
zeroshade merged commit 5a3a6f1 into apache:main Sep 2, 2025
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.

New rest.Catalog option to allow custom Transport

2 participants