Skip to content

Commit 00310b0

Browse files
committed
refactor
1 parent 5205677 commit 00310b0

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

cache.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,11 @@ func CacheByRequestBody(defaultCacheStore persist.CacheStore, defaultExpire time
207207
cacheStrategy := func(c *gin.Context) (bool, Strategy) {
208208
requestBody, err := c.GetRawData()
209209
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(requestBody))
210-
211210
if err != nil {
212211
return false, Strategy{}
213212
}
214213
h := crypto.SHA256.New()
215-
_, err = h.Write(requestBody)
216-
if err != nil {
217-
return false, Strategy{}
218-
}
219-
bodyHash := string(h.Sum(nil))
214+
bodyHash := string(h.Sum(requestBody))
220215
return true, Strategy{
221216
CacheKey: bodyHash,
222217
}

0 commit comments

Comments
 (0)