mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
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
|
StatusPingTimeout = 4002
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var emptyObject = json.RawMessage("{}")
|
||||||
|
|
||||||
func (gmx *Gomuks) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
func (gmx *Gomuks) HandleWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Header.Get("Sec-Fetch-Mode") != "websocket" {
|
if r.Header.Get("Sec-Fetch-Mode") != "websocket" {
|
||||||
ErrInvalidHeader.WithMessage("Invalid Sec-Fetch-Dest header").Write(w)
|
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)
|
closeOnce.Do(forceClose)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if cmd.Data == nil {
|
||||||
|
cmd.Data = emptyObject
|
||||||
|
}
|
||||||
log.Trace().
|
log.Trace().
|
||||||
Int64("req_id", cmd.RequestID).
|
Int64("req_id", cmd.RequestID).
|
||||||
Str("command", cmd.Command).
|
Str("command", cmd.Command).
|
||||||
|
|
Loading…
Add table
Reference in a new issue