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 9577570 commit 7162d18Copy full SHA for 7162d18
event.go
@@ -3,9 +3,11 @@ package esl
3
import (
4
"bufio"
5
"bytes"
6
+ "encoding/json"
7
"fmt"
8
"io"
9
"log/slog"
10
+ "maps"
11
"net/url"
12
"slices"
13
"strconv"
@@ -106,6 +108,17 @@ func (e Event) String() string {
106
108
return wstr(e)
107
109
}
110
111
+// MarshalJSON is a Go function that marshals the Event to JSON.
112
+func (e Event) MarshalJSON() ([]byte, error) {
113
+ h := e.headers
114
+ if len(e.body) > 0 {
115
+ h = maps.Clone(h)
116
+ h["_body"] = string(e.body)
117
+ }
118
+
119
+ return json.Marshal(h)
120
+}
121
122
// LogValue returns the log value of the Event.
123
//
124
// It returns a slog.Value that contains the name and sequence of the Event.
0 commit comments