mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
pkg/web: remove dependency injection (#49123)
* pkg/web: store http.Handler internally * pkg/web: remove injection Removes any injection code from pkg/web. It already was no longer functional, as we already only injected into `http.Handler`, meaning we only inject ctx.Req and ctx.Resp. Any other types (*Context, *ReqContext) were already accessed using the http.Request.Context.Value() method. * *: remove type mappings Removes any call to the previously removed TypeMapper, as those were non-functional already. * pkg/web: remove Context.Invoke was no longer used outside of pkg/web and also no longer functional
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
legacyMetrics "github.com/grafana/grafana/pkg/services/alerting/metrics"
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
@@ -279,20 +278,14 @@ func (m *OrgRegistries) RemoveOrgRegistry(org int64) {
|
||||
func Instrument(
|
||||
method,
|
||||
path string,
|
||||
action interface{},
|
||||
action func(*models.ReqContext) response.Response,
|
||||
metrics *API,
|
||||
) web.Handler {
|
||||
normalizedPath := MakeLabelValue(path)
|
||||
|
||||
return func(c *models.ReqContext) {
|
||||
start := time.Now()
|
||||
var res response.Response
|
||||
val, err := c.Invoke(action)
|
||||
if err == nil && val != nil && len(val) > 0 {
|
||||
res = val[0].Interface().(response.Response)
|
||||
} else {
|
||||
res = routing.ServerError(err)
|
||||
}
|
||||
res := action(c)
|
||||
|
||||
// TODO: We could look up the datasource type via our datasource service
|
||||
var backend string
|
||||
|
||||
Reference in New Issue
Block a user