Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added RedirectResponse as a convenient method for issuing a redirect

  • Loading branch information...
commit 6a1bf83af464f367c9cb090b5418f2624c71765c 1 parent 3e86d9c
@dgrijalva dgrijalva authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 response.go
View
12 response.go
@@ -32,3 +32,15 @@ func (s *fixedResBody) Close() error {
func (s *fixedResBody) Read(b []byte) (int, error) {
return (*strings.Reader)(s).Read(b)
}
+
+func RedirectResponse(req *http.Request, url string) *http.Response {
+ res := new(http.Response)
+ res.StatusCode = 302
+ res.ProtoMajor = 1
+ res.ProtoMinor = 1
+ res.ContentLength = 0
+ res.Request = req
+ res.Header = make(map[string][]string)
+ res.Header.Set("Location", url)
+ return res
+}
Please sign in to comment.
Something went wrong with that request. Please try again.