Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 86c23d6

Browse files
authored
fix: re-order parameters (#23)
* fix: re-order parameters * fix: rename the function name
1 parent 7b6bb9e commit 86c23d6

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

httpcache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func newClient(client *http.Client, rfcCompliance bool, cacheInteractor cache.IC
2121
if client.Transport == nil {
2222
client.Transport = http.DefaultTransport
2323
}
24-
cachedHandler = NewRoundtrip(client.Transport, cacheInteractor, rfcCompliance)
24+
cachedHandler = NewCacheHandlerRoundtrip(client.Transport, rfcCompliance, cacheInteractor)
2525
client.Transport = cachedHandler
2626
return
2727
}

roundtriper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type CacheHandler struct {
3030
ComplyRFC bool
3131
}
3232

33-
// NewRoundtrip will create an implementations of cache http roundtripper
34-
func NewRoundtrip(defaultRoundTripper http.RoundTripper, cacheActor cache.ICacheInteractor, rfcCompliance bool) *CacheHandler {
33+
// NewCacheHandlerRoundtrip will create an implementations of cache http roundtripper
34+
func NewCacheHandlerRoundtrip(defaultRoundTripper http.RoundTripper, rfcCompliance bool, cacheActor cache.ICacheInteractor) *CacheHandler {
3535
if cacheActor == nil {
3636
log.Fatal("cache interactor is nil")
3737
}

roundtripper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestSetToCacheRoundtrip(t *testing.T) {
2020
mockCacheInteractor.On("Get", mock.AnythingOfType("string")).Once().Return(cachedResponse, errors.New("uknown error"))
2121
mockCacheInteractor.On("Set", mock.AnythingOfType("string"), mock.Anything).Once().Return(nil)
2222
client := &http.Client{}
23-
client.Transport = httpcache.NewRoundtrip(http.DefaultTransport, mockCacheInteractor, true)
23+
client.Transport = httpcache.NewCacheHandlerRoundtrip(http.DefaultTransport, true, mockCacheInteractor)
2424
// HTTP GET 200
2525
jsonResp := []byte(`{"message": "Hello World!"}`)
2626
handler := func() (res http.Handler) {

0 commit comments

Comments
 (0)