mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 07:35:45 -06:00
* Chore: Refactor api handlers to use web.Bind * fix comments * fix comment * trying to fix most of the tests and force routing.Wrap type check * fix library panels tests * fix frontend logging tests * allow passing nil as a response to skip writing * return nil instead of the response * rewrite login handler function types * remove handlerFuncCtx * make linter happy * remove old bindings from the libraryelements * restore comments
22 lines
447 B
Go
22 lines
447 B
Go
package routing
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/web"
|
|
)
|
|
|
|
var (
|
|
ServerError = func(err error) response.Response {
|
|
return response.Error(500, "Server error", err)
|
|
}
|
|
)
|
|
|
|
func Wrap(handler func(c *models.ReqContext) response.Response) web.Handler {
|
|
return func(c *models.ReqContext) {
|
|
if res := handler(c); res != nil {
|
|
res.WriteTo(c)
|
|
}
|
|
}
|
|
}
|