Commit 216b6b01 by Arve Knudsen Committed by GitHub

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

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 433b8610
......@@ -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}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment