forked from Mirrors/gomuks
websocket: fix logging commands with no data
This commit is contained in:
parent
4eec9f5eb6
commit
e909f4f994
1 changed files with 5 additions and 0 deletions
|
@ -51,6 +51,8 @@ const (
|
|||
StatusPingTimeout = 4002
|
||||
)
|
||||
|
||||
var emptyObject = json.RawMessage("{}")
|
||||
|
||||
func (gmx *Gomuks) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get("Sec-Fetch-Mode") != "websocket" {
|
||||
ErrInvalidHeader.WithMessage("Invalid Sec-Fetch-Dest header").Write(w)
|
||||
|
@ -156,6 +158,9 @@ func (gmx *Gomuks) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
|||
closeOnce.Do(forceClose)
|
||||
}
|
||||
}()
|
||||
if cmd.Data == nil {
|
||||
cmd.Data = emptyObject
|
||||
}
|
||||
log.Trace().
|
||||
Int64("req_id", cmd.RequestID).
|
||||
Str("command", cmd.Command).
|
||||
|
|
Loading…
Add table
Reference in a new issue