Chore: Move ReqContext to contexthandler service (#62102)

* Chore: Move ReqContext to contexthandler service

* Rename package to contextmodel

* Generate ngalert files

* Remove unused imports
This commit is contained in:
idafurjes
2023-01-27 08:50:36 +01:00
committed by GitHub
parent 8379a29b53
commit 6c5a573772
180 changed files with 1208 additions and 1182 deletions
+7 -7
View File
@@ -7,17 +7,17 @@ import (
"fmt"
"net/http"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/web"
)
type (
handlerStd = func(http.ResponseWriter, *http.Request)
handlerStdCtx = func(http.ResponseWriter, *http.Request, *web.Context)
handlerStdReqCtx = func(http.ResponseWriter, *http.Request, *models.ReqContext)
handlerReqCtx = func(*models.ReqContext)
handlerReqCtxRes = func(*models.ReqContext) Response
handlerStdReqCtx = func(http.ResponseWriter, *http.Request, *contextmodel.ReqContext)
handlerReqCtx = func(*contextmodel.ReqContext)
handlerReqCtxRes = func(*contextmodel.ReqContext) Response
handlerCtx = func(*web.Context)
)
@@ -67,11 +67,11 @@ func webCtx(w http.ResponseWriter, r *http.Request) *web.Context {
return ctx
}
func reqCtx(w http.ResponseWriter, r *http.Request) *models.ReqContext {
func reqCtx(w http.ResponseWriter, r *http.Request) *contextmodel.ReqContext {
wCtx := webCtx(w, r)
reqCtx, ok := wCtx.Req.Context().Value(ctxkey.Key{}).(*models.ReqContext)
reqCtx, ok := wCtx.Req.Context().Value(ctxkey.Key{}).(*contextmodel.ReqContext)
if !ok {
panic("no *models.ReqContext found")
panic("no *contextmodel.ReqContext found")
}
return reqCtx
}