Use referer in error template
This commit is contained in:
parent
850a83eebe
commit
5616fce5b4
1 changed files with 9 additions and 4 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue