|
@@ -15,6 +15,8 @@
|
|
|
|
|
|
package hub
|
|
package hub
|
|
|
|
|
|
|
|
+import "encoding/json"
|
|
|
|
+
|
|
// Message gets converted to/from JSON and sent in the body of pubsub messages.
|
|
// Message gets converted to/from JSON and sent in the body of pubsub messages.
|
|
type Message struct {
|
|
type Message struct {
|
|
Message string
|
|
Message string
|
|
@@ -53,3 +55,11 @@ func (m *Message) WithMessage(s string) *Message {
|
|
copy.Message = s
|
|
copy.Message = s
|
|
return copy
|
|
return copy
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func (m *Message) AnnotationsToObj(v interface{}) error {
|
|
|
|
+ blob, err := json.Marshal(m.Annotations)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ return json.Unmarshal(blob, v)
|
|
|
|
+}
|