grafana/pkg/api/routing/routing.go
idafurjes 6c5a573772
Chore: Move ReqContext to contexthandler service (#62102)
* Chore: Move ReqContext to contexthandler service

* Rename package to contextmodel

* Generate ngalert files

* Remove unused imports
2023-01-27 08:50:36 +01:00

22 lines
495 B
Go

package routing
import (
"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(500, "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)
}
}
}