Fix racy modification of NotFoundHandler.

This commit is contained in:
Kamil Kisiel
2014-06-04 14:12:38 -07:00
parent 0ef595e787
commit 854d482e26

6
mux.go
View File

@@ -87,10 +87,10 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
setCurrentRoute(req, match.Route)
}
if handler == nil {
if r.NotFoundHandler == nil {
r.NotFoundHandler = http.NotFoundHandler()
}
handler = r.NotFoundHandler
if handler == nil {
handler = http.NotFoundHandler()
}
}
if !r.KeepContext {
defer context.Clear(req)