Skip to content

Commit

Permalink
Fix roundtrip loglevel
Browse files Browse the repository at this point in the history
  • Loading branch information
hons82 committed Oct 13, 2021
1 parent d490757 commit 51ff58a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,18 @@ func (s *Server) listen(l net.Listener, identifier id.ID) {
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
resp, err := s.RoundTrip(r)
if err != nil {
level := 0
code := http.StatusBadGateway
if err == errUnauthorised {
w.Header().Set("WWW-Authenticate", "Basic realm=\"User Visible Realm\"")
level = 1
code = http.StatusUnauthorized
} else if err == errClientNotSubscribed {
level = 2
code = http.StatusNotFound
}
s.logger.Log(
"level", 0,
"level", level,
"action", "round trip failed",
"addr", r.RemoteAddr,
"host", r.Host,
Expand Down

0 comments on commit 51ff58a

Please sign in to comment.