待机配置
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user