Skip to content

Commit

Permalink
added tlsState to every log message
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed Nov 21, 2024
1 parent 5453dc5 commit dbb2661
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xhttp/xhttpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func NewServerChain(o Options, l *zap.Logger, fbs ...sallusthttp.FieldBuilder) a
bs.Add(func(r *http.Request, l *zap.Logger) *zap.Logger {
return l.With(zap.String("userAgent", r.UserAgent()))
})
bs.Add(func(r *http.Request, l *zap.Logger) *zap.Logger {
return l.With(connectionStateField("state", r.TLS))
})

chain := alice.New(
ResponseHeaders{Header: o.Header}.Then,
Expand All @@ -73,10 +76,7 @@ func NewServerChain(o Options, l *zap.Logger, fbs ...sallusthttp.FieldBuilder) a
func(next http.Handler) http.Handler {
return http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
requestLogger := bs.Build(request, l)
requestLogger.Info(
"tls info",
connectionStateField("state", request.TLS),
)
requestLogger.Info("request received")

next.ServeHTTP(
response,
Expand Down

0 comments on commit dbb2661

Please sign in to comment.