Skip to content

Commit

Permalink
Lint fixes 6/n
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont committed Jun 26, 2022
1 parent c810b24 commit fa91ece
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions poll.go
Expand Up @@ -335,7 +335,18 @@ func (h *Headscale) PollNetMapStream(

return
}
writer.(http.Flusher).Flush()

flusher, ok := writer.(http.Flusher)
if !ok {
log.Error().
Caller().
Str("handler", "PollNetMapStream").
Str("machine", machine.Hostname).
Str("channel", "pollData").
Msg("Cannot cast writer to http.Flusher")
} else {
flusher.Flush()
}

log.Trace().
Str("handler", "PollNetMapStream").
Expand Down Expand Up @@ -403,7 +414,17 @@ func (h *Headscale) PollNetMapStream(

return
}
writer.(http.Flusher).Flush()
flusher, ok := writer.(http.Flusher)
if !ok {
log.Error().
Caller().
Str("handler", "PollNetMapStream").
Str("machine", machine.Hostname).
Str("channel", "keepAlive").
Msg("Cannot cast writer to http.Flusher")
} else {
flusher.Flush()
}

log.Trace().
Str("handler", "PollNetMapStream").
Expand Down Expand Up @@ -492,7 +513,18 @@ func (h *Headscale) PollNetMapStream(

return
}
writer.(http.Flusher).Flush()

flusher, ok := writer.(http.Flusher)
if !ok {
log.Error().
Caller().
Str("handler", "PollNetMapStream").
Str("machine", machine.Hostname).
Str("channel", "update").
Msg("Cannot cast writer to http.Flusher")
} else {
flusher.Flush()
}

log.Trace().
Str("handler", "PollNetMapStream").
Expand Down

0 comments on commit fa91ece

Please sign in to comment.