Skip to content

Commit

Permalink
runtime: Use simple defaults syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Nov 10, 2023
1 parent 146dadd commit b1e60cd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions runtime/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ func NewServeMux(opts ...ServeMuxOption) *ServeMux {
opt(serveMux)
}

for matcher, fallback := range map[*HeaderMatcherFunc]HeaderMatcherFunc{
&serveMux.incomingHeaderMatcher: DefaultHeaderMatcher,
&serveMux.outgoingHeaderMatcher: defaultOutgoingHeaderMatcher,
&serveMux.outgoingTrailerMatcher: defaultOutgoingTrailerMatcher,
} {
if *matcher == nil {
*matcher = fallback
}
if serveMux.incomingHeaderMatcher == nil {
serveMux.incomingHeaderMatcher = DefaultHeaderMatcher
}
if serveMux.outgoingHeaderMatcher == nil {
serveMux.outgoingHeaderMatcher = defaultOutgoingHeaderMatcher
}
if serveMux.outgoingTrailerMatcher == nil {
serveMux.outgoingTrailerMatcher = defaultOutgoingTrailerMatcher
}

return serveMux
Expand Down

0 comments on commit b1e60cd

Please sign in to comment.