grokify/go-ringcentral-client

Configuration.Transport type issue

Closed this issue · 1 comments

When attempting to use client.Transport in Configuration, the following error is encountered.

code: examples/get_extension/get_extension.go

error:

./get_extension.go:30: cannot use client.Transport (type http.RoundTripper) as type *http.Transport in assignment: need type assertion

This is to support Resty:

// SetTransport method sets custom `*http.Transport` or any `http.RoundTripper`
// compatible interface implementation in the resty client.
//
// Please Note:
//
// - If transport is not type of `*http.Transport` then you may not be able to
// take advantage of some of the `resty` client settings.
//
// - It overwrites the resty client transport instance and it's configurations.
//
//		transport := &http.Transport{
//			// somthing like Proxying to httptest.Server, etc...
//			Proxy: func(req *http.Request) (*url.URL, error) {
//				return url.Parse(server.URL)
//			},
//		}
//
//		resty.SetTransport(transport)
//
func (c *Client) SetTransport(transport http.RoundTripper) *Client {
	if transport != nil {
		c.httpClient.Transport = transport
	}
	return c
}

Fixed in 5936ff8

Changed Configuration.Transport type to http.RoundTripper from *http.Transport