Skip to content

Commit

Permalink
feat: support reset response's header function
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Apr 1, 2019
1 parent 5450ba6 commit 92a1e66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ func (c *Context) AddHeader(key, value string) {
c.Headers.Add(key, value)
}

// ResetHeader reset response header
func (c *Context) ResetHeader() {
h := c.Header()
for k := range h {
h.Del(k)
}
}

// Cookie get cookie from http request
func (c *Context) Cookie(name string) (*http.Cookie, error) {
return c.Request.Cookie(name)
Expand Down
7 changes: 7 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ func TestGetSetHeader(t *testing.T) {
t.Fatalf("header function fail")
}
})

t.Run("reset header", func(t *testing.T) {
c.ResetHeader()
if len(c.Header()) != 0 {
t.Fatalf("reset header fail")
}
})
}

func TestCookie(t *testing.T) {
Expand Down

0 comments on commit 92a1e66

Please sign in to comment.