diff --git a/middleware/replacer.go b/middleware/replacer.go index 6f47dfef..aea14bff 100644 --- a/middleware/replacer.go +++ b/middleware/replacer.go @@ -53,9 +53,11 @@ func NewReplacer(r *http.Request, rr *responseRecorder) replacer { "{when}": func() string { return time.Now().Format(timeFormat) }(), - "{status}": strconv.Itoa(rr.status), - "{size}": strconv.Itoa(rr.size), - "{latency}": time.Since(rr.start).String(), + } + if rr != nil { + rep["{status}"] = strconv.Itoa(rr.status) + rep["{size}"] = strconv.Itoa(rr.size) + rep["{latency}"] = time.Since(rr.start).String() } // Header placeholders