From 57bf87258f41c1cebc25f96e21400bc31ae6545e Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 24 Aug 2017 08:27:15 -0700 Subject: [PATCH] Fixed #995 Signed-off-by: Vishal Rana --- echo.go | 2 +- response.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/echo.go b/echo.go index 54d9d510..d6b3f51c 100644 --- a/echo.go +++ b/echo.go @@ -295,7 +295,7 @@ func New() (e *Echo) { func (e *Echo) NewContext(r *http.Request, w http.ResponseWriter) Context { return &context{ request: r, - response: &Response{echo: e, Writer: w}, + response: NewResponse(w, e), store: make(Map), echo: e, pvalues: make([]string, *e.maxParam), diff --git a/response.go b/response.go index 68b99155..b23931ae 100644 --- a/response.go +++ b/response.go @@ -20,6 +20,11 @@ type ( } ) +// NewResponse creates a new instance of Response. +func NewResponse(w http.ResponseWriter, e *Echo) (r *Response) { + return &Response{Writer: w, echo: e} +} + // Header returns the header map for the writer that will be sent by // WriteHeader. Changing the header after a call to WriteHeader (or Write) has // no effect unless the modified headers were declared as trailers by setting