mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
RedirectResponse: Implement all of api.Response (#29946)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
433b861093
commit
216b6b01f4
@ -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…
Reference in New Issue
Block a user