Browse Source

Add WriteRedirect helper func

master
Matt Baer 7 years ago
parent
commit
b97c7b280f
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      response.go

+ 7
- 0
response.go View File

@@ -59,3 +59,10 @@ func WriteError(w http.ResponseWriter, e HTTPError) error {
}
return renderJSON(w, env, e.Status)
}

// WriteRedirect sends a redirect
func WriteRedirect(w http.ResponseWriter, e HTTPError) int {
w.Header().Set("Location", e.Message)
w.WriteHeader(e.Status)
return e.Status
}

Loading…
Cancel
Save