API: adds redirect helper to simplify http redirects (#19180)

pull/19191/head
Leonard Gram 6 years ago committed by GitHub
parent 75bf31b5c7
commit dd794625dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      pkg/api/common.go

@ -135,3 +135,15 @@ func Respond(status int, body interface{}) *NormalResponse {
header: make(http.Header),
}
}
type RedirectResponse struct {
location string
}
func (r *RedirectResponse) WriteTo(ctx *m.ReqContext) {
ctx.Redirect(r.location)
}
func Redirect(location string) *RedirectResponse {
return &RedirectResponse{location: location}
}

Loading…
Cancel
Save