supabase-community / postgrest-go

Isomorphic Go client for PostgREST. (Now Updating)
https://supabase.io
Apache License 2.0
170 stars 27 forks source link

Feature client transport config #40

Closed Fritte795 closed 8 months ago

Fritte795 commented 10 months ago

What kind of change does this PR introduce?

Add the possibility to define custom transport settings for the http.Client. Furthermore the renaming prevents stuttering (former Client.clientTransport)

What is the current behavior?

Any information can be found in #39

What is the new behavior?

It is now possible to define custom transport behavior by setting Client.Transport.Parent:

func main() {
    c := postgrest.NewClient("localhost:3000", "", nil)

    c.Transport.Parent = &http.Transport{
        TLSClientConfig: &tls.Config{
            RootCAs:            x509.NewCertPool(),
            InsecureSkipVerify: false,
        },
    }
}

Additional information

Due to the behavior of httpmock used for testing, the implemented RoundTrip() is not as clean as it could be. For testing with httpmock to work properly http.DefaultTransport.RoundTrip() must be called in RoundTrip() in client.go.

tranhoangvuit commented 8 months ago

Hi @Fritte795, it looks good to me, but could you please resolve the conflict first?

muratmirgun commented 8 months ago

@tranhoangvuit I will fix this conflicts tonight

elijahmorg commented 5 months ago

This PR clobbered the changes made in #41

In current main you cannot set apikey and token separately.