Skip to content

Commit

Permalink
adds web.Redirect()
Browse files Browse the repository at this point in the history
  • Loading branch information
jritsema committed Dec 12, 2024
1 parent d54589c commit 02db668
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ func Empty(status int) *Response {
return Data(status, []byte(""), nil)
}

// Sends an HTTP 302 redirect
func Redirect(location string) *Response {
return &Response{
Status: http.StatusFound,
Content: bytes.NewBuffer(nil),
Headers: map[string]string{
"Location": location,
},
}
}

// HTML renders an html template to a web response
func HTML(status int, t *template.Template, template string, data interface{}, headers Headers) *Response {

Expand Down

0 comments on commit 02db668

Please sign in to comment.