Skip to content

Commit

Permalink
handle nil opts gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny committed Apr 26, 2024
1 parent e3c53f1 commit 266329e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ type HandlerOptions = slog.HandlerOptions
//
// Basically it replaces `opts.ReplaceAttr` with [ReplaceAttr].
func NewHandler(w io.Writer, opts *HandlerOptions) *slog.JSONHandler {
if opts == nil {
opts = &HandlerOptions{}
}
opts.ReplaceAttr = ReplaceAttr
return slog.NewJSONHandler(w, opts)
}

0 comments on commit 266329e

Please sign in to comment.