From 216b6b01f446b6bc7c298401207df37e5dc7e61c Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Mon, 21 Dec 2020 13:44:22 +0100 Subject: [PATCH] RedirectResponse: Implement all of api.Response (#29946) Signed-off-by: Arve Knudsen --- pkg/api/common.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/api/common.go b/pkg/api/common.go index cbb44ec3d97..bb9f7a1f5e1 100644 --- a/pkg/api/common.go +++ b/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} }