From f40370103bba9ae17458f6973204f4a88ba247cf Mon Sep 17 00:00:00 2001 From: Thanatat Tamtan Date: Sat, 23 Sep 2023 12:52:57 +0700 Subject: [PATCH] fix linter warning --- context.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index 63f9e58..6997ed9 100644 --- a/context.go +++ b/context.go @@ -64,15 +64,17 @@ func (ctx *Context) Value(key any) any { } // WithRequest returns new context with given request -func (ctx Context) WithRequest(r *http.Request) *Context { - ctx.Request = r - return &ctx +func (ctx *Context) WithRequest(r *http.Request) *Context { + nctx := *ctx + nctx.Request = r + return &nctx } // WithResponseWriter returns new context with given response writer -func (ctx Context) WithResponseWriter(w http.ResponseWriter) *Context { - ctx.w = w - return &ctx +func (ctx *Context) WithResponseWriter(w http.ResponseWriter) *Context { + nctx := *ctx + nctx.w = w + return &nctx } // WithContext returns new context with new request with given context