diff --git a/httpcache.go b/httpcache.go index bec8b76..112c6f7 100644 --- a/httpcache.go +++ b/httpcache.go @@ -21,7 +21,7 @@ func newClient(client *http.Client, rfcCompliance bool, cacheInteractor cache.IC if client.Transport == nil { client.Transport = http.DefaultTransport } - cachedHandler = NewRoundtrip(client.Transport, cacheInteractor, rfcCompliance) + cachedHandler = NewCacheHandlerRoundtrip(client.Transport, rfcCompliance, cacheInteractor) client.Transport = cachedHandler return } diff --git a/roundtriper.go b/roundtriper.go index 92e3754..17e93ef 100644 --- a/roundtriper.go +++ b/roundtriper.go @@ -30,8 +30,8 @@ type CacheHandler struct { ComplyRFC bool } -// NewRoundtrip will create an implementations of cache http roundtripper -func NewRoundtrip(defaultRoundTripper http.RoundTripper, cacheActor cache.ICacheInteractor, rfcCompliance bool) *CacheHandler { +// NewCacheHandlerRoundtrip will create an implementations of cache http roundtripper +func NewCacheHandlerRoundtrip(defaultRoundTripper http.RoundTripper, rfcCompliance bool, cacheActor cache.ICacheInteractor) *CacheHandler { if cacheActor == nil { log.Fatal("cache interactor is nil") } diff --git a/roundtripper_test.go b/roundtripper_test.go index 25b952a..fc46a92 100644 --- a/roundtripper_test.go +++ b/roundtripper_test.go @@ -20,7 +20,7 @@ func TestSetToCacheRoundtrip(t *testing.T) { mockCacheInteractor.On("Get", mock.AnythingOfType("string")).Once().Return(cachedResponse, errors.New("uknown error")) mockCacheInteractor.On("Set", mock.AnythingOfType("string"), mock.Anything).Once().Return(nil) client := &http.Client{} - client.Transport = httpcache.NewRoundtrip(http.DefaultTransport, mockCacheInteractor, true) + client.Transport = httpcache.NewCacheHandlerRoundtrip(http.DefaultTransport, true, mockCacheInteractor) // HTTP GET 200 jsonResp := []byte(`{"message": "Hello World!"}`) handler := func() (res http.Handler) {