RedirectResponse: Implement all of api.Response (#29946)

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
pull/29952/head
Arve Knudsen 5 years ago committed by GitHub
parent 433b861093
commit 216b6b01f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      pkg/api/common.go

@ -144,19 +144,28 @@ func Respond(status int, body interface{}) *NormalResponse {
}
}
// RedirectResponse represents a redirect response.
type RedirectResponse struct {
location string
}
// WriteTo writes to a response.
func (r *RedirectResponse) WriteTo(ctx *models.ReqContext) {
ctx.Redirect(r.location)
}
// Status gets the response's status.
// Required to implement api.Response.
func (*RedirectResponse) Status() int {
return http.StatusFound
}
// Body gets the response's body.
// Required to implement api.Response.
func (r *RedirectResponse) Body() []byte {
return nil
}
func Redirect(location string) *RedirectResponse {
return &RedirectResponse{location: location}
}

Loading…
Cancel
Save