justinas / alice

Painless middleware chaining for Go

Home Page:https://godoc.org/github.com/justinas/alice

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why DefaultServeMux is selected as nil replacement in calls to Then?

Komosa opened this issue · comments

Additional question: why not do nothing handler?, like:

http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})

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.