aboutsummaryrefslogtreecommitdiff
path: root/xP
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-09-14 04:29:31 +0200
committerPřemysl Eric Janouch <p@janouch.name>2022-09-14 06:56:36 +0200
commitc1d2e38840c0596efd10e97ff5a9edaa20d5457e (patch)
treef1d56b745e9a8f1d649c442f52a3f0ddcf5d795b /xP
parentf89f21a47fd2764ab48d908dd93dd78f8ff8b471 (diff)
downloadxK-c1d2e38840c0596efd10e97ff5a9edaa20d5457e.tar.gz
xK-c1d2e38840c0596efd10e97ff5a9edaa20d5457e.tar.xz
xK-c1d2e38840c0596efd10e97ff5a9edaa20d5457e.zip
xP: generate our own JSON marshallers
For non-trivial types, which are expensive to serialize with encoding/json's struct reflection.
Diffstat (limited to 'xP')
-rw-r--r--xP/xP.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/xP/xP.go b/xP/xP.go
index dc5aa5e..2d6e096 100644
--- a/xP/xP.go
+++ b/xP/xP.go
@@ -50,7 +50,7 @@ func relayReadJSON(conn net.Conn) []byte {
return nil
}
- j, err := json.Marshal(&m)
+ j, err := m.MarshalJSON()
if err != nil {
log.Println("Event marshalling failed: " + err.Error())
return nil
@@ -126,7 +126,7 @@ func clientWriteJSON(ctx context.Context, ws *websocket.Conn, j []byte) bool {
}
func clientWriteError(ctx context.Context, ws *websocket.Conn, err error) bool {
- j, err := json.Marshal(&RelayEventMessage{
+ j, err := (&RelayEventMessage{
EventSeq: 0,
Data: RelayEventData{
Interface: RelayEventDataError{
@@ -135,7 +135,7 @@ func clientWriteError(ctx context.Context, ws *websocket.Conn, err error) bool {
Error: err.Error(),
},
},
- })
+ }).MarshalJSON()
if err != nil {
log.Println("Event marshalling failed: " + err.Error())
return false