We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ace3b0a commit 433f774Copy full SHA for 433f774
event.go
@@ -120,6 +120,21 @@ func (e Event) MarshalJSON() ([]byte, error) {
120
return json.Marshal(h)
121
}
122
123
+// UnmarshalJSON is a Go function that unmarshal the Event from JSON.
124
+func (e *Event) UnmarshalJSON(data []byte) error {
125
+ e.headers = make(map[string]string)
126
+ if err := json.Unmarshal(data, &e.headers); err != nil {
127
+ return err
128
+ }
129
+
130
+ if e.headers["_body"] != "" {
131
+ e.body = []byte(e.headers["_body"])
132
+ delete(e.headers, "_body")
133
134
135
+ return nil
136
+}
137
138
// LogValue returns the log value of the Event.
139
//
140
// It returns a slog.Value that contains the name and sequence of the Event.
0 commit comments