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