From 54fda903fdd7ad32ce03ccbf0b7fe9bf074e98c1 Mon Sep 17 00:00:00 2001 From: vicanso Date: Sat, 19 Sep 2020 10:54:13 +0800 Subject: [PATCH] refactor: init context params in new context function --- context.go | 1 + context_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/context.go b/context.go index f3af90c..701df68 100644 --- a/context.go +++ b/context.go @@ -624,5 +624,6 @@ func NewContext(resp http.ResponseWriter, req *http.Request) *Context { c := &Context{} c.Request = req c.Response = resp + c.Params = new(RouteParams) return c } diff --git a/context_test.go b/context_test.go index 94daa0d..3ebc855 100644 --- a/context_test.go +++ b/context_test.go @@ -79,6 +79,7 @@ func TestContext(t *testing.T) { data := "abcd" assert := assert.New(t) c := NewContext(nil, nil) + assert.NotNil(c.Params) c.WriteHeader(http.StatusBadRequest) assert.Equal(c.StatusCode, http.StatusBadRequest) _, err := c.Write([]byte(data))