增加待机报文缓存,无网状态也能执行待机任务;投影仪指令结果以设备状态为准
This commit is contained in:
18
internal/middleware/cache.go
Normal file
18
internal/middleware/cache.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"game-driver/config"
|
||||
"game-driver/leaf"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Cache 缓存中间件
|
||||
func Cache(cache config.Cache) leaf.HandlerFunc {
|
||||
return func(c *leaf.Context) {
|
||||
err := cache.Set(c.Publish)
|
||||
if err != nil {
|
||||
zap.S().Errorln("缓存数据失败: ", err)
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user