File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -94,18 +94,21 @@ func cloneHeaders(src http.Header) http.Header {
94
94
}
95
95
96
96
func (h handler ) getCacheKey (req * http.Request ) string {
97
+ hash := sha256 .New ()
98
+ hash .Write ([]byte (req .Method ))
99
+ hash .Write ([]byte (":" ))
100
+ hash .Write ([]byte (req .URL .Path ))
101
+
97
102
// Check for global cache keys first
98
103
for pattern , globalKey := range h .cfg .GlobalCacheKeys {
99
104
if strings .HasPrefix (req .URL .Path , pattern ) {
100
- return globalKey
105
+ hash .Write ([]byte (":" ))
106
+ hash .Write ([]byte (globalKey ))
107
+
108
+ return fmt .Sprintf ("%x" , hash .Sum (nil ))
101
109
}
102
110
}
103
111
104
- hash := sha256 .New ()
105
- hash .Write ([]byte (req .Method ))
106
- hash .Write ([]byte (":" ))
107
- hash .Write ([]byte (req .URL .Path ))
108
-
109
112
if h .cfg .ShouldHashQuery {
110
113
query := req .URL .Query ()
111
114
keys := make ([]string , 0 , len (query ))
You can’t perform that action at this time.
0 commit comments