Added Redirect function

This commit is contained in:
Eduard Urbach 2024-04-02 16:17:43 +02:00
parent 3f303d8e09
commit 1f62562d70
Signed by: eduard
GPG key ID: 49226B848C78F6C8
3 changed files with 22 additions and 0 deletions

View file

@ -55,3 +55,15 @@ func TestErrorMultiple(t *testing.T) {
assert.Equal(t, response.Status(), 401)
assert.Equal(t, string(response.Body()), "")
}
func TestRedirect(t *testing.T) {
s := web.NewServer()
s.Get("/", func(ctx web.Context) error {
return ctx.Redirect(301, "/target")
})
response := s.Request("GET", "/", nil, nil)
assert.Equal(t, response.Status(), 301)
assert.Equal(t, response.Header("Location"), "/target")
}