Handle context cancellations and avoid logged errors.

This commit is contained in:
mikestefanello 2022-01-09 00:23:26 -05:00
parent a6e99058f4
commit 10c0a23c0a
8 changed files with 83 additions and 35 deletions

View file

@ -51,11 +51,15 @@ func ServeCachedPage(ch *cache.Cache) echo.MiddlewareFunc {
new(CachedPage),
)
if err != nil {
if err == redis.Nil {
switch {
case err == redis.Nil:
c.Logger().Info("no cached page found")
} else {
case context.IsCanceledError(err):
return nil
default:
c.Logger().Errorf("failed getting cached page: %v", err)
}
return next(c)
}