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:
Serge Zaitsev
2021-09-14 18:34:56 +02:00
committed by GitHub
parent fb1c31e1b6
commit 063160aae2
41 changed files with 177 additions and 158 deletions
+2 -1
View File
@@ -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)