mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: pass url parameters through context.Context (#38826)
* pass url parameters through context.Context * fix url param names without colon prefix * change context params to vars * replace url vars in tests using new api * rename vars to params * add some comments * rename seturlvars to seturlparams
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/ngalert/notifier"
|
||||
"github.com/grafana/grafana/pkg/services/search"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func ValidateOrgAlert(c *models.ReqContext) {
|
||||
@@ -255,7 +256,7 @@ func GetAlertNotificationByID(c *models.ReqContext) response.Response {
|
||||
func GetAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
query := &models.GetAlertNotificationsWithUidQuery{
|
||||
OrgId: c.OrgId,
|
||||
Uid: c.Params("uid"),
|
||||
Uid: macaron.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if query.Uid == "" {
|
||||
@@ -315,7 +316,7 @@ func UpdateAlertNotification(c *models.ReqContext, cmd models.UpdateAlertNotific
|
||||
|
||||
func UpdateAlertNotificationByUID(c *models.ReqContext, cmd models.UpdateAlertNotificationWithUidCommand) response.Response {
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.Uid = c.Params("uid")
|
||||
cmd.Uid = macaron.Params(c.Req)[":uid"]
|
||||
|
||||
err := fillWithSecureSettingsDataByUID(&cmd)
|
||||
if err != nil {
|
||||
@@ -408,7 +409,7 @@ func DeleteAlertNotification(c *models.ReqContext) response.Response {
|
||||
func DeleteAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
cmd := models.DeleteAlertNotificationWithUidCommand{
|
||||
OrgId: c.OrgId,
|
||||
Uid: c.Params("uid"),
|
||||
Uid: macaron.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
|
||||
@@ -58,7 +58,7 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
|
||||
|
||||
func AppPluginRoute(route *plugins.AppPluginRoute, appID string, hs *HTTPServer) macaron.Handler {
|
||||
return func(c *models.ReqContext) {
|
||||
path := c.Params("*")
|
||||
path := macaron.Params(c.Req)["*"]
|
||||
|
||||
proxy := pluginproxy.NewApiPluginProxy(c, path, route, appID, hs.Cfg)
|
||||
proxy.Transport = pluginProxyTransport
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
gocache "github.com/patrickmn/go-cache"
|
||||
)
|
||||
@@ -77,7 +78,7 @@ type CacheServer struct {
|
||||
var validMD5 = regexp.MustCompile("^[a-fA-F0-9]{32}$")
|
||||
|
||||
func (a *CacheServer) Handler(ctx *models.ReqContext) {
|
||||
hash := ctx.Params("hash")
|
||||
hash := macaron.Params(ctx.Req)[":hash"]
|
||||
|
||||
if len(hash) != 32 || !validMD5.MatchString(hash) {
|
||||
ctx.JsonApiErr(404, "Avatar not found", nil)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/alerting"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
@@ -70,7 +71,7 @@ func (hs *HTTPServer) TrimDashboard(c *models.ReqContext, cmd models.TrimDashboa
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
||||
uid := c.Params(":uid")
|
||||
uid := macaron.Params(c.Req)[":uid"]
|
||||
dash, rsp := getDashboardHelper(c.Req.Context(), c.OrgId, 0, uid)
|
||||
if rsp != nil {
|
||||
return rsp
|
||||
@@ -214,7 +215,7 @@ func getDashboardHelper(ctx context.Context, orgID int64, id int64, uid string)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) DeleteDashboardBySlug(c *models.ReqContext) response.Response {
|
||||
query := models.GetDashboardsBySlugQuery{OrgId: c.OrgId, Slug: c.Params(":slug")}
|
||||
query := models.GetDashboardsBySlugQuery{OrgId: c.OrgId, Slug: macaron.Params(c.Req)[":slug"]}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
return response.Error(500, "Failed to retrieve dashboards by slug", err)
|
||||
@@ -232,7 +233,7 @@ func (hs *HTTPServer) DeleteDashboardByUID(c *models.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) deleteDashboard(c *models.ReqContext) response.Response {
|
||||
dash, rsp := getDashboardHelper(c.Req.Context(), c.OrgId, 0, c.Params(":uid"))
|
||||
dash, rsp := getDashboardHelper(c.Req.Context(), c.OrgId, 0, macaron.Params(c.Req)[":uid"])
|
||||
if rsp != nil {
|
||||
return rsp
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
var client = &http.Client{
|
||||
@@ -145,7 +146,7 @@ func CreateDashboardSnapshot(c *models.ReqContext, cmd models.CreateDashboardSna
|
||||
|
||||
// GET /api/snapshots/:key
|
||||
func GetDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
key := c.Params(":key")
|
||||
key := macaron.Params(c.Req)[":key"]
|
||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||
|
||||
err := bus.Dispatch(query)
|
||||
@@ -209,7 +210,7 @@ func deleteExternalDashboardSnapshot(externalUrl string) error {
|
||||
|
||||
// GET /api/snapshots-delete/:deleteKey
|
||||
func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response {
|
||||
key := c.Params(":deleteKey")
|
||||
key := macaron.Params(c.Req)[":deleteKey"]
|
||||
|
||||
query := &models.GetDashboardSnapshotQuery{DeleteKey: key}
|
||||
|
||||
@@ -239,7 +240,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
|
||||
|
||||
// DELETE /api/snapshots/:key
|
||||
func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
key := c.Params(":key")
|
||||
key := macaron.Params(c.Req)[":key"]
|
||||
|
||||
query := &models.GetDashboardSnapshotQuery{Key: key}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/plugins/adapters"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
)
|
||||
@@ -117,7 +118,7 @@ func (hs *HTTPServer) DeleteDataSourceById(c *models.ReqContext) response.Respon
|
||||
|
||||
// GET /api/datasources/uid/:uid
|
||||
func GetDataSourceByUID(c *models.ReqContext) response.Response {
|
||||
ds, err := getRawDataSourceByUID(c.Params(":uid"), c.OrgId)
|
||||
ds, err := getRawDataSourceByUID(macaron.Params(c.Req)[":uid"], c.OrgId)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
@@ -132,7 +133,7 @@ func GetDataSourceByUID(c *models.ReqContext) response.Response {
|
||||
|
||||
// DELETE /api/datasources/uid/:uid
|
||||
func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Response {
|
||||
uid := c.Params(":uid")
|
||||
uid := macaron.Params(c.Req)[":uid"]
|
||||
|
||||
if uid == "" {
|
||||
return response.Error(400, "Missing datasource uid", nil)
|
||||
@@ -163,7 +164,7 @@ func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Respo
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Response {
|
||||
name := c.Params(":name")
|
||||
name := macaron.Params(c.Req)[":name"]
|
||||
|
||||
if name == "" {
|
||||
return response.Error(400, "Missing valid datasource name", nil)
|
||||
@@ -328,7 +329,7 @@ func getRawDataSourceByUID(uid string, orgID int64) (*models.DataSource, error)
|
||||
|
||||
// Get /api/datasources/name/:name
|
||||
func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: c.Params(":name"), OrgId: c.OrgId}
|
||||
query := models.GetDataSourceQuery{Name: macaron.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
@@ -343,7 +344,7 @@ func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
|
||||
// Get /api/datasources/id/:name
|
||||
func GetDataSourceIdByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: c.Params(":name"), OrgId: c.OrgId}
|
||||
query := models.GetDataSourceQuery{Name: macaron.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
@@ -391,7 +392,7 @@ func (hs *HTTPServer) CallDatasourceResource(c *models.ReqContext) {
|
||||
PluginID: plugin.Id,
|
||||
DataSourceInstanceSettings: dsInstanceSettings,
|
||||
}
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, c.Params("*"))
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, macaron.Params(c.Req)["*"])
|
||||
}
|
||||
|
||||
func convertModelToDtos(ds *models.DataSource) dtos.DataSource {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/services/libraryelements"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response {
|
||||
@@ -38,7 +39,7 @@ func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response {
|
||||
|
||||
func (hs *HTTPServer) GetFolderByUID(c *models.ReqContext) response.Response {
|
||||
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), c.Params(":uid"))
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), macaron.Params(c.Req)[":uid"])
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
@@ -78,7 +79,7 @@ func (hs *HTTPServer) CreateFolder(c *models.ReqContext, cmd models.CreateFolder
|
||||
|
||||
func (hs *HTTPServer) UpdateFolder(c *models.ReqContext, cmd models.UpdateFolderCommand) response.Response {
|
||||
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
err := s.UpdateFolder(c.Req.Context(), c.Params(":uid"), &cmd)
|
||||
err := s.UpdateFolder(c.Req.Context(), macaron.Params(c.Req)[":uid"], &cmd)
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
@@ -89,7 +90,7 @@ func (hs *HTTPServer) UpdateFolder(c *models.ReqContext, cmd models.UpdateFolder
|
||||
|
||||
func (hs *HTTPServer) DeleteFolder(c *models.ReqContext) response.Response { // temporarily adding this function to HTTPServer, will be removed from HTTPServer when librarypanels featuretoggle is removed
|
||||
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
err := hs.LibraryElementService.DeleteLibraryElementsInFolder(c, c.Params(":uid"))
|
||||
err := hs.LibraryElementService.DeleteLibraryElementsInFolder(c, macaron.Params(c.Req)[":uid"])
|
||||
if err != nil {
|
||||
if errors.Is(err, libraryelements.ErrFolderHasConnectedLibraryElements) {
|
||||
return response.Error(403, "Folder could not be deleted because it contains library elements in use", err)
|
||||
@@ -97,7 +98,7 @@ func (hs *HTTPServer) DeleteFolder(c *models.ReqContext) response.Response { //
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
f, err := s.DeleteFolder(c.Req.Context(), c.Params(":uid"), c.QueryBool("forceDeleteRules"))
|
||||
f, err := s.DeleteFolder(c.Req.Context(), macaron.Params(c.Req)[":uid"], c.QueryBool("forceDeleteRules"))
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetFolderPermissionList(c *models.ReqContext) response.Response {
|
||||
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), c.Params(":uid"))
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), macaron.Params(c.Req)[":uid"])
|
||||
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
@@ -63,7 +64,7 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *models.ReqContext, apiCmd dtos.
|
||||
}
|
||||
|
||||
s := dashboards.NewFolderService(c.OrgId, c.SignedInUser, hs.SQLStore)
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), c.Params(":uid"))
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), macaron.Params(c.Req)[":uid"])
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
var grafanaComProxyTransport = &http.Transport{
|
||||
@@ -41,7 +42,7 @@ func ReverseProxyGnetReq(proxyPath string) *httputil.ReverseProxy {
|
||||
}
|
||||
|
||||
func ProxyGnetRequest(c *models.ReqContext) {
|
||||
proxyPath := c.Params("*")
|
||||
proxyPath := macaron.Params(c.Req)["*"]
|
||||
proxy := ReverseProxyGnetReq(proxyPath)
|
||||
proxy.Transport = grafanaComProxyTransport
|
||||
proxy.ServeHTTP(c.Resp, c.Req)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/ldap"
|
||||
"github.com/grafana/grafana/pkg/services/multildap"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -238,7 +239,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
|
||||
ldap := newLDAP(ldapConfig.Servers)
|
||||
|
||||
username := c.Params(":username")
|
||||
username := macaron.Params(c.Req)[":username"]
|
||||
|
||||
if len(username) == 0 {
|
||||
return response.Error(http.StatusBadRequest, "Validation error. You must specify an username", nil)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"net/url"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
@@ -41,7 +42,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) {
|
||||
loginInfo := models.LoginInfo{
|
||||
AuthModule: "oauth",
|
||||
}
|
||||
name := ctx.Params(":name")
|
||||
name := macaron.Params(ctx.Req)[":name"]
|
||||
loginInfo.AuthModule = name
|
||||
provider := hs.SocialService.GetOAuthInfoProvider(name)
|
||||
if provider == nil {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
// GET /api/org
|
||||
@@ -24,7 +25,7 @@ func GetOrgByID(c *models.ReqContext) response.Response {
|
||||
|
||||
// Get /api/orgs/name/:name
|
||||
func (hs *HTTPServer) GetOrgByName(c *models.ReqContext) response.Response {
|
||||
org, err := hs.SQLStore.GetOrgByName(c.Params(":name"))
|
||||
org, err := hs.SQLStore.GetOrgByName(macaron.Params(c.Req)[":name"])
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrOrgNotFound) {
|
||||
return response.Error(404, "Organization not found", err)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func GetPendingOrgInvites(c *models.ReqContext) response.Response {
|
||||
@@ -131,7 +132,7 @@ func inviteExistingUserToOrg(c *models.ReqContext, user *models.User, inviteDto
|
||||
}
|
||||
|
||||
func RevokeInvite(c *models.ReqContext) response.Response {
|
||||
if ok, rsp := updateTempUserStatus(c.Params(":code"), models.TmpUserRevoked); !ok {
|
||||
if ok, rsp := updateTempUserStatus(macaron.Params(c.Req)[":code"], models.TmpUserRevoked); !ok {
|
||||
return rsp
|
||||
}
|
||||
|
||||
@@ -142,7 +143,7 @@ func RevokeInvite(c *models.ReqContext) response.Response {
|
||||
// A response containing an InviteInfo object is returned if the invite is found.
|
||||
// If a (pending) invite is not found, 404 is returned.
|
||||
func GetInviteInfoByCode(c *models.ReqContext) response.Response {
|
||||
query := models.GetTempUserByCodeQuery{Code: c.Params(":code")}
|
||||
query := models.GetTempUserByCodeQuery{Code: macaron.Params(c.Req)[":code"]}
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if errors.Is(err, models.ErrTempUserNotFound) {
|
||||
return response.Error(404, "Invite not found", nil)
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager/installer"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetPluginList(c *models.ReqContext) response.Response {
|
||||
@@ -100,7 +101,7 @@ func (hs *HTTPServer) GetPluginList(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params(":pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
def := hs.PluginManager.GetPlugin(pluginID)
|
||||
if def == nil {
|
||||
@@ -145,7 +146,7 @@ func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) UpdatePluginSetting(c *models.ReqContext, cmd models.UpdatePluginSettingCmd) response.Response {
|
||||
pluginID := c.Params(":pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
if app := hs.PluginManager.GetApp(pluginID); app == nil {
|
||||
return response.Error(404, "Plugin not installed", nil)
|
||||
@@ -161,7 +162,7 @@ func (hs *HTTPServer) UpdatePluginSetting(c *models.ReqContext, cmd models.Updat
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginDashboards(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params(":pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
list, err := hs.PluginManager.GetPluginDashboards(c.OrgId, pluginID)
|
||||
if err != nil {
|
||||
@@ -177,8 +178,8 @@ func (hs *HTTPServer) GetPluginDashboards(c *models.ReqContext) response.Respons
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginMarkdown(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params(":pluginId")
|
||||
name := c.Params(":name")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
name := macaron.Params(c.Req)[":name"]
|
||||
|
||||
content, err := hs.PluginManager.GetPluginMarkdown(pluginID, name)
|
||||
if err != nil {
|
||||
@@ -235,7 +236,7 @@ func (hs *HTTPServer) ImportDashboard(c *models.ReqContext, apiCmd dtos.ImportDa
|
||||
//
|
||||
// /api/plugins/:pluginId/metrics
|
||||
func (hs *HTTPServer) CollectPluginMetrics(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||
if plugin == nil {
|
||||
return response.Error(404, "Plugin not found", nil)
|
||||
@@ -256,14 +257,14 @@ func (hs *HTTPServer) CollectPluginMetrics(c *models.ReqContext) response.Respon
|
||||
//
|
||||
// /public/plugins/:pluginId/*
|
||||
func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||
if plugin == nil {
|
||||
c.JsonApiErr(404, "Plugin not found", nil)
|
||||
return
|
||||
}
|
||||
|
||||
requestedFile := filepath.Clean(c.Params("*"))
|
||||
requestedFile := filepath.Clean(macaron.Params(c.Req)["*"])
|
||||
pluginFilePath := filepath.Join(plugin.PluginDir, requestedFile)
|
||||
|
||||
if !plugin.IncludedInSignature(requestedFile) {
|
||||
@@ -307,7 +308,7 @@ func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) {
|
||||
// CheckHealth returns the health of a plugin.
|
||||
// /api/plugins/:pluginId/health
|
||||
func (hs *HTTPServer) CheckHealth(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
pCtx, found, err := hs.PluginContextProvider.Get(pluginID, "", c.SignedInUser, false)
|
||||
if err != nil {
|
||||
@@ -349,7 +350,7 @@ func (hs *HTTPServer) CheckHealth(c *models.ReqContext) response.Response {
|
||||
//
|
||||
// /api/plugins/:pluginId/resources/*
|
||||
func (hs *HTTPServer) CallResource(c *models.ReqContext) {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
pCtx, found, err := hs.PluginContextProvider.Get(pluginID, "", c.SignedInUser, false)
|
||||
if err != nil {
|
||||
@@ -360,7 +361,7 @@ func (hs *HTTPServer) CallResource(c *models.ReqContext) {
|
||||
c.JsonApiErr(404, "Plugin not found", nil)
|
||||
return
|
||||
}
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, c.Params("*"))
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, macaron.Params(c.Req)["*"])
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginErrorsList(_ *models.ReqContext) response.Response {
|
||||
@@ -368,7 +369,7 @@ func (hs *HTTPServer) GetPluginErrorsList(_ *models.ReqContext) response.Respons
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) InstallPlugin(c *models.ReqContext, dto dtos.InstallPluginCommand) response.Response {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
err := hs.PluginManager.Install(c.Req.Context(), pluginID, dto.Version)
|
||||
if err != nil {
|
||||
@@ -399,7 +400,7 @@ func (hs *HTTPServer) InstallPlugin(c *models.ReqContext, dto dtos.InstallPlugin
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) UninstallPlugin(c *models.ReqContext) response.Response {
|
||||
pluginID := c.Params("pluginId")
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
|
||||
err := hs.PluginManager.Uninstall(c.Req.Context(), pluginID)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func GetOrgQuotas(c *models.ReqContext) response.Response {
|
||||
@@ -25,7 +26,7 @@ func UpdateOrgQuota(c *models.ReqContext, cmd models.UpdateOrgQuotaCmd) response
|
||||
return response.Error(404, "Quotas not enabled", nil)
|
||||
}
|
||||
cmd.OrgId = c.ParamsInt64(":orgId")
|
||||
cmd.Target = c.Params(":target")
|
||||
cmd.Target = macaron.Params(c.Req)[":target"]
|
||||
|
||||
if _, ok := setting.Quota.Org.ToMap()[cmd.Target]; !ok {
|
||||
return response.Error(404, "Invalid quota target", nil)
|
||||
@@ -55,7 +56,7 @@ func UpdateUserQuota(c *models.ReqContext, cmd models.UpdateUserQuotaCmd) respon
|
||||
return response.Error(404, "Quotas not enabled", nil)
|
||||
}
|
||||
cmd.UserId = c.ParamsInt64(":id")
|
||||
cmd.Target = c.Params(":target")
|
||||
cmd.Target = macaron.Params(c.Req)[":target"]
|
||||
|
||||
if _, ok := setting.Quota.User.ToMap()[cmd.Target]; !ok {
|
||||
return response.Error(404, "Invalid quota target", nil)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
|
||||
@@ -58,7 +59,7 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
|
||||
OrgID: c.OrgId,
|
||||
UserID: c.UserId,
|
||||
OrgRole: c.OrgRole,
|
||||
Path: c.Params("*") + queryParams,
|
||||
Path: macaron.Params(c.Req)["*"] + queryParams,
|
||||
Timezone: queryReader.Get("tz", ""),
|
||||
Encoding: queryReader.Get("encoding", ""),
|
||||
ConcurrentLimit: hs.Cfg.RendererConcurrentRequestLimit,
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
// createShortURL handles requests to create short URLs.
|
||||
@@ -45,7 +46,7 @@ func (hs *HTTPServer) createShortURL(c *models.ReqContext, cmd dtos.CreateShortU
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) redirectFromShortURL(c *models.ReqContext) {
|
||||
shortURLUID := c.Params(":uid")
|
||||
shortURLUID := macaron.Params(c.Req)[":uid"]
|
||||
|
||||
if !util.IsValidShortUID(shortURLUID) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user