Skip to content

Commit

Permalink
Merge pull request #259 from xmidt-org/feature/log-security-requested…
Browse files Browse the repository at this point in the history
…-items

added user-agent and the sallust default fields to the request logger
  • Loading branch information
johnabass authored Nov 20, 2024
2 parents 5486f7a + 9e63a67 commit bf64eaa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xhttp/xhttpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ type Options struct {
// NewServerChain produces the standard constructor chain for a server, primarily using configuration.
func NewServerChain(o Options, l *zap.Logger, fbs ...sallusthttp.FieldBuilder) alice.Chain {
bs := sallusthttp.Builders{}
bs.AddFields(fbs...)
bs.Add(sallusthttp.DefaultFields)
bs.Add(func(r *http.Request, l *zap.Logger) *zap.Logger {
return l.With(zap.String("userAgent", r.UserAgent()))
})

chain := alice.New(
ResponseHeaders{Header: o.Header}.Then,
Busy{MaxConcurrentRequests: o.MaxConcurrentRequests}.Then,
)

bs.AddFields(fbs...)
if !o.DisableTracking {
chain = chain.Append(UseTrackingWriter)
}
Expand Down

0 comments on commit bf64eaa

Please sign in to comment.