attestantio/go-eth2-client

Support passing a custom *http.Client

Closed this issue · 3 comments

jybp commented

AFAICT there is no way to currently pass a custom *http.Client to the lib. Meaning consumers have no way to configure it nor can they use custom http.RoundTrippers. It's usually a good practice to have that possibility.

https://github.com/attestantio/go-eth2-client/blob/e02b07f2405232b26018a50a25d9fcd9ed75c205/http/service.go/#L97-L110

Example:
https://github.com/google/go-github/blob/3d410c20b3a7e4496f5b86b7d85c0a51dbaf782e/github/github.go#L315-L328

It's usually passed in a specific constructor or within a functional option.
func WithHttpClient(client *http.Client) Parameter could be added in parameters.go

I could work toward a PR if maintainers have no bandwidth.

mcdee commented

Please could you take a look at #170 and see if this meets your requirement? Thanks.

jybp commented

Yes this looks great. Thanks Jim.

mcdee commented

Closed by #170