diff --git a/handlers/handlers.go b/handlers/handlers.go index 3acbc1fa..fb45e738 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -495,14 +495,19 @@ func DefaultHomeHandler() http.Handler { } func (m *rootMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { - err := m.fn(w, r) // Call handler function - if err == nil { + var errData struct { + Error error + Referer string + } + errData.Error = m.fn(w, r) // Call handler function + if errData.Error == nil { return } // This is where our error handling logic starts. if m.h.Config.LogLevel > config.LOG_LEVEL_OFF { - log.Printf("An error accured: %v", err) // Log the error. + log.Printf("An error accured: %v", errData.Error) // Log the error. } - respondWithError(m.h, w, r, err) + errData.Referer = r.Header.Get("Referer") + respondWithError(m.h, w, r, errData) }