PublicDashboards: Variables refactor (#73476)

Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com>
Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Torkel Ödegaard
2023-08-25 13:56:02 -05:00
committed by GitHub
co-authored by Juan Cabanas Ezequiel Victorero Ryan McKinley
parent 2245a3d0d1
commit 3ee26df41e
37 changed files with 147 additions and 204 deletions
+6 -2
View File
@@ -30,8 +30,8 @@ type ReqContext struct {
Logger log.Logger
Error error
// RequestNonce is a cryptographic request identifier for use with Content Security Policy.
RequestNonce string
IsPublicDashboardView bool
RequestNonce string
PublicDashboardAccessToken string
PerfmonTimer prometheus.Summary
LookupTokenErr error
@@ -60,6 +60,10 @@ func (ctx *ReqContext) IsApiRequest() bool {
return strings.HasPrefix(ctx.Req.URL.Path, "/api")
}
func (ctx *ReqContext) IsPublicDashboardView() bool {
return ctx.PublicDashboardAccessToken != ""
}
func (ctx *ReqContext) JsonApiErr(status int, message string, err error) {
resp := make(map[string]interface{})
traceID := tracing.TraceIDFromContext(ctx.Req.Context(), false)