Use referer in error template

This commit is contained in:
Andrea Fazzi 2020-01-28 09:36:57 +01:00
parent 850a83eebe
commit 5616fce5b4

View file

@ -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)
}