Skip to content

Commit 9f49621

Browse files
committed
feat: v1.4.3
1 parent 036fefb commit 9f49621

12 files changed

+100
-24
lines changed

Dockerfile-dev

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ ADD ./default /app/src/github.com/darkweak/souin/default
2121
ADD ./errors /app/src/github.com/darkweak/souin/errors
2222
ADD ./helpers /app/src/github.com/darkweak/souin/helpers
2323
ADD ./providers /app/src/github.com/darkweak/souin/providers
24-
ADD ./plugins /app/src/github.com/darkweak/souin/plugins
2524

2625
WORKDIR /app/src/github.com/darkweak/souin
2726

2827
EXPOSE 80
2928

30-
CMD ["go", "run", "plugins/souin/main.go"]
29+
CMD ["go", "run", "main.go"]

Dockerfile-prod

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ ADD ./default /app/src/github.com/darkweak/souin/default
2121
ADD ./errors /app/src/github.com/darkweak/souin/errors
2222
ADD ./helpers /app/src/github.com/darkweak/souin/helpers
2323
ADD ./providers /app/src/github.com/darkweak/souin/providers
24-
ADD ./plugins /app/src/github.com/darkweak/souin/plugins
2524

2625
WORKDIR /app/src/github.com/darkweak/souin
2726
RUN go mod download

api/souin.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212

1313
// SouinAPI object contains informations related to the endpoints
1414
type SouinAPI struct {
15-
basePath string
16-
enabled bool
15+
basePath string
16+
enabled bool
1717
providers map[string]types.AbstractProviderInterface
18-
security *auth.SecurityAPI
18+
security *auth.SecurityAPI
1919
}
2020

2121
func initializeSouin(providers map[string]types.AbstractProviderInterface, configuration configurationtypes.AbstractConfigurationInterface, api *auth.SecurityAPI) *SouinAPI {

api/souin_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func TestSouinAPI_BulkDelete(t *testing.T) {
2626
souinMock := mockSouinAPI()
2727
defer souinMock.providers["olric"].Reset()
2828
for _, provider := range souinMock.providers {
29-
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 20 * time.Second)
30-
provider.Set("key2", []byte("value"), tests.GetMatchedURL("key"), 20 * time.Second)
29+
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 20*time.Second)
30+
provider.Set("key2", []byte("value"), tests.GetMatchedURL("key"), 20*time.Second)
3131
}
3232
time.Sleep(3 * time.Second)
3333
for _, v := range souinMock.GetAll() {
@@ -48,7 +48,7 @@ func TestSouinAPI_Delete(t *testing.T) {
4848
souinMock := mockSouinAPI()
4949
defer souinMock.providers["olric"].Reset()
5050
for _, provider := range souinMock.providers {
51-
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 20 * time.Second)
51+
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 20*time.Second)
5252
}
5353
time.Sleep(3 * time.Second)
5454
for _, v := range souinMock.GetAll() {
@@ -75,7 +75,7 @@ func TestSouinAPI_GetAll(t *testing.T) {
7575
}
7676

7777
for _, provider := range souinMock.providers {
78-
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 6 * time.Second)
78+
provider.Set("key", []byte("value"), tests.GetMatchedURL("key"), 6*time.Second)
7979
}
8080
time.Sleep(3 * time.Second)
8181
for _, v := range souinMock.GetAll() {

cache/coalescing/requestCoalescing_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestServeResponse(t *testing.T) {
1818
rc := Initialize()
1919
retriever := &types.RetrieverResponseProperties{
2020
Configuration: c,
21-
Providers: prs,
21+
Providers: prs,
2222
MatchedURL: tests.GetMatchedURL(tests.PATH),
2323
RegexpUrls: regexpUrls,
2424
}

cache/providers/olricProvider.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// Olric provider type
1313
type Olric struct {
1414
*client.Client
15-
dm *client.DMap
15+
dm *client.DMap
1616
keySaver *keysaver.ClearKey
1717
}
1818

@@ -65,7 +65,7 @@ func (provider *Olric) Get(key string) []byte {
6565
func (provider *Olric) Set(key string, value []byte, url t.URL, duration time.Duration) {
6666
if duration == 0 {
6767
ttl, _ := strconv.Atoi(url.TTL)
68-
duration = time.Duration(ttl)*time.Second
68+
duration = time.Duration(ttl) * time.Second
6969
}
7070

7171
err := provider.dm.PutEx(key, value, duration)

cache/providers/olricProvider_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestIShouldBeAbleToReadAndWriteDataInOlric(t *testing.T) {
2626
client, u := getOlricClientAndMatchedURL("Test")
2727
defer client.Reset()
2828
client.Set("Test", []byte(OLRICVALUE), u, time.Duration(10)*time.Second)
29-
time.Sleep(3*time.Second)
29+
time.Sleep(3 * time.Second)
3030
res := client.Get("Test")
3131
if OLRICVALUE != string(res) {
3232
errors.GenerateError(t, fmt.Sprintf("%s not corresponding to %s", res, OLRICVALUE))
@@ -45,15 +45,15 @@ func TestOlric_GetRequestInCache(t *testing.T) {
4545
func TestOlric_SetRequestInCache_OneByte(t *testing.T) {
4646
client, u := getOlricClientAndMatchedURL(BYTEKEY)
4747
defer client.Reset()
48-
client.Set(BYTEKEY, []byte{65}, u, time.Duration(20) * time.Second)
48+
client.Set(BYTEKEY, []byte{65}, u, time.Duration(20)*time.Second)
4949
}
5050

5151
func TestOlric_SetRequestInCache_TTL(t *testing.T) {
5252
key := "MyEmptyKey"
5353
client, matchedURL := getOlricClientAndMatchedURL(key)
5454
defer client.Reset()
5555
nv := []byte("Hello world")
56-
setValueThenVerify(client, key, nv, matchedURL, time.Duration(20) * time.Second, t)
56+
setValueThenVerify(client, key, nv, matchedURL, time.Duration(20)*time.Second, t)
5757
}
5858

5959
func TestOlric_SetRequestInCache_NoTTL(t *testing.T) {

cache/providers/redisProvider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (provider *Redis) Get(key string) []byte {
5555
func (provider *Redis) Set(key string, value []byte, url t.URL, duration time.Duration) {
5656
if duration == 0 {
5757
ttl, _ := strconv.Atoi(url.TTL)
58-
duration = time.Duration(ttl)*time.Second
58+
duration = time.Duration(ttl) * time.Second
5959
}
6060

6161
err := provider.Client.Set(provider.Context(), key, string(value), duration).Err()

cache/providers/redisProvider_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ func TestRedis_GetRequestInCache(t *testing.T) {
4040

4141
func TestRedis_SetRequestInCache_OneByte(t *testing.T) {
4242
client, u := getRedisClientAndMatchedURL(BYTEKEY)
43-
client.Set(BYTEKEY, []byte{65}, u, time.Duration(20) * time.Second)
43+
client.Set(BYTEKEY, []byte{65}, u, time.Duration(20)*time.Second)
4444
}
4545

4646
func TestRedis_SetRequestInCache_TTL(t *testing.T) {
4747
key := "MyEmptyKey"
4848
client, matchedURL := getRedisClientAndMatchedURL(key)
4949
nv := []byte("Hello world")
50-
setValueThenVerify(client, key, nv, matchedURL, time.Duration(20) * time.Second, t)
50+
setValueThenVerify(client, key, nv, matchedURL, time.Duration(20)*time.Second, t)
5151
}
5252

5353
func TestRedis_SetRequestInCache_NoTTL(t *testing.T) {

cache/service/responseRetriever_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestServeResponse(t *testing.T) {
2727
w,
2828
r,
2929
retriever,
30-
func(rw http.ResponseWriter, rq *http.Request, r types.RetrieverResponsePropertiesInterface, key string) {},
30+
func(rw http.ResponseWriter, rq *http.Request, r types.RetrieverResponsePropertiesInterface, key string) {
31+
},
3132
)
3233
}

cache/types/souin.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ type TransportInterface interface {
2121
type Transport struct {
2222
// The RoundTripper interface actually used to make requests
2323
// If nil, http.DefaultTransport is used
24-
Transport http.RoundTripper
25-
Providers map[string]AbstractProviderInterface
26-
ConfigurationURL configurationtypes.URL
24+
Transport http.RoundTripper
25+
Providers map[string]AbstractProviderInterface
26+
ConfigurationURL configurationtypes.URL
2727
// If true, responses returned from the cache will be given an extra header, X-From-Cache
2828
MarkCachedResponses bool
2929
}
@@ -73,7 +73,7 @@ func (r *RetrieverResponseProperties) SetMatchedURL(url configurationtypes.URL)
7373
providers = append(providers, k)
7474
}
7575
}
76-
url.Providers= providers
76+
url.Providers = providers
7777
r.MatchedURL = url
7878
}
7979

0 commit comments

Comments
 (0)