待机配置

This commit is contained in:
2024-11-05 18:39:03 +08:00
parent ccfe0d311b
commit 8e2bf7f59b
15 changed files with 384 additions and 132 deletions

View File

@@ -12,14 +12,14 @@ type JSONKey string
const PayloadJSONKey JSONKey = "payload_json"
// PayloadJSON 解析报文
func PayloadJSON() leaf.HandlerFunc {
func PayloadJSON[T schema.JsonModel]() leaf.HandlerFunc {
return func(c *leaf.Context) {
pm := &schema.PlayModal{}
pm := new(T)
err := json.Unmarshal(c.Payload, pm)
if err != nil {
log.Panicf("报文解析错误: %v\n", err)
}
leaf.WithValue[*schema.PlayModal](c, PayloadJSONKey, pm)
leaf.WithValue[*T](c, PayloadJSONKey, pm)
c.Next()
}
}