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

Commit

Permalink
fix: re-order parameters (#23)
Browse files Browse the repository at this point in the history
* fix: re-order parameters

* fix: rename the function name
  • Loading branch information
bxcodec authored Jun 22, 2020
1 parent 7b6bb9e commit 86c23d6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion httpcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions roundtriper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion roundtripper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 86c23d6

Please sign in to comment.