Skip to content

Commit

Permalink
API: adds redirect helper to simplify http redirects (grafana#19180)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlson authored Sep 17, 2019
1 parent 75bf31b commit dd79462
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

0 comments on commit dd79462

Please sign in to comment.