@@ -12,6 +12,7 @@ import (
12
12
13
13
"github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/authx/models"
14
14
"github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/config"
15
+ "github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/log"
15
16
responsehandler "github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/response-handler"
16
17
"github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/s3client"
17
18
utils "github.com/oxyno-zeta/s3-proxy/pkg/s3-proxy/utils/generalutils"
@@ -42,15 +43,24 @@ func (bri *bucketReqImpl) generateStartKey(requestPath string) string {
42
43
func (bri * bucketReqImpl ) manageKeyRewrite (ctx context.Context , key string ) (string , error ) {
43
44
// Check if key rewrite list exists
44
45
if bri .targetCfg .KeyRewriteList != nil {
46
+ // Get logger
47
+ logger := log .GetLoggerFromContext (ctx )
48
+
45
49
// Loop over key rewrite list
46
50
for _ , kr := range bri .targetCfg .KeyRewriteList {
47
51
// Check if key is matching
48
52
if kr .SourceRegex .MatchString (key ) {
53
+ // Debug log
54
+ logger .Debugf ("Rewrite key : Key %s is matching the source rewrite %s" , key , kr .SourceRegex .String ())
55
+
49
56
// Find submatches
50
57
submatches := kr .SourceRegex .FindStringSubmatchIndex (key )
51
58
52
59
// Check if there isn't any submatch
53
60
if len (submatches ) == 0 {
61
+ // Debug log
62
+ logger .Debugf ("Rewrite key : Key %s have been changed to %s" , key , kr .Target )
63
+
54
64
return kr .Target , nil
55
65
}
56
66
@@ -60,6 +70,10 @@ func (bri *bucketReqImpl) manageKeyRewrite(ctx context.Context, key string) (str
60
70
result := []byte {}
61
71
// Replace matches in target
62
72
result = kr .SourceRegex .ExpandString (result , kr .Target , key , submatches )
73
+
74
+ // Debug log
75
+ logger .Debugf ("Rewrite key : Key %s have been changed to %s" , key , string (result ))
76
+
63
77
// Return result
64
78
return string (result ), nil
65
79
}
@@ -113,6 +127,9 @@ func (bri *bucketReqImpl) manageKeyRewrite(ctx context.Context, key string) (str
113
127
// Trim spaces
114
128
str = strings .TrimSpace (str )
115
129
130
+ // Debug log
131
+ logger .Debugf ("Rewrite key : Key %s have been changed to %s" , key , str )
132
+
116
133
return str , nil
117
134
}
118
135
}
0 commit comments