mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
add convenience method for casting payloads
This commit is contained in:
@@ -104,11 +104,11 @@ func init() {
|
||||
return nil, errors.New("mqtt.message.create payload error: not found")
|
||||
}
|
||||
|
||||
if payloadBytes, ok := payload.([]byte); ok {
|
||||
if payloadBytes, ok := GetAnyAs[[]byte](payload); ok {
|
||||
return &MQTTMessageCreate{config: config, Topic: topicString, QoS: byte(qosByte), Retained: retainedBool, Payload: payloadBytes}, nil
|
||||
}
|
||||
|
||||
payloadString, ok := payload.(string)
|
||||
payloadString, ok := GetAnyAs[string](payload)
|
||||
|
||||
if !ok {
|
||||
return nil, errors.New("mqtt.message.create payload error: not a string or byte array")
|
||||
|
||||
Reference in New Issue
Block a user