Why DefaultServeMux is selected as nil replacement in calls to Then?
Komosa opened this issue · comments
Komosa commented
Additional question: why not do nothing handler?, like:
http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
Justinas Stankevičius commented
Hi,
This replicates the behavior seen in net/http.Serve()
(or ListenAndServe()
), which also substitutes nil
with DefaultServeMux
.
My other idea for handling nil
was to panic, but this seemed like a less scary alternative and a nice shortcut for those using DefaultServeMux
.
A do-nothing handler is, I think, a rare case and easy to spin-out yourself.