fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

client: Allow custom Doer (#690)

This PR makes the httpClient an interface with the minimal surface area required by the stream.Client.
This lets us inject a custom doer more easily, which can be beneficial for testing, and in the case of Sourcegraph, lets us augment the Doer with middlewares.

+8 -2
+8 -2
stream/client.go
··· 11 11 "github.com/sourcegraph/zoekt/query" 12 12 ) 13 13 14 + // Doer implements the minimal surface of *http.Client and http.RoundTripper needed 15 + // by Client. 16 + type Doer interface { 17 + Do(*http.Request) (*http.Response, error) 18 + } 19 + 14 20 // NewClient returns a client which implements StreamSearch. If httpClient is 15 21 // nil, http.DefaultClient is used. 16 - func NewClient(address string, httpClient *http.Client) *Client { 22 + func NewClient(address string, httpClient Doer) *Client { 17 23 registerGob() 18 24 if httpClient == nil { 19 25 httpClient = http.DefaultClient ··· 31 37 address string 32 38 33 39 // httpClient when set is used instead of http.DefaultClient 34 - httpClient *http.Client 40 + httpClient Doer 35 41 } 36 42 37 43 // SenderFunc is an adapter to allow the use of ordinary functions as Sender.