From 082ae70d1d9cb08188d5f50fcba31dd4f4bab20c Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Sun, 3 May 2015 12:38:06 -0700 Subject: [PATCH] Allow responseRecorder to be nil --- middleware/replacer.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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