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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user