mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
* Chore: Replace response status with const var * Apply suggestions from code review Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> * Add net/http import --------- Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
24 lines
535 B
Go
24 lines
535 B
Go
package routing
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
|
"github.com/grafana/grafana/pkg/web"
|
|
)
|
|
|
|
var (
|
|
ServerError = func(err error) response.Response {
|
|
return response.Error(http.StatusInternalServerError, "Server error", err)
|
|
}
|
|
)
|
|
|
|
func Wrap(handler func(c *contextmodel.ReqContext) response.Response) web.Handler {
|
|
return func(c *contextmodel.ReqContext) {
|
|
if res := handler(c); res != nil {
|
|
res.WriteTo(c)
|
|
}
|
|
}
|
|
}
|