Chore: replace macaron with web package (#40136)

* replace macaron with web package

* add web.go
This commit is contained in:
Serge Zaitsev
2021-10-11 14:30:59 +02:00
committed by GitHub
parent 78ebac0116
commit 57fcfd578d
70 changed files with 369 additions and 375 deletions

View File

@ -17,7 +17,7 @@ import (
"github.com/grafana/grafana/pkg/plugins/adapters"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
"gopkg.in/macaron.v1"
"github.com/grafana/grafana/pkg/web"
)
var datasourcesLogger = log.New("datasources")
@ -119,7 +119,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(macaron.Params(c.Req)[":uid"], c.OrgId)
ds, err := getRawDataSourceByUID(web.Params(c.Req)[":uid"], c.OrgId)
if err != nil {
if errors.Is(err, models.ErrDataSourceNotFound) {
@ -134,7 +134,7 @@ func GetDataSourceByUID(c *models.ReqContext) response.Response {
// DELETE /api/datasources/uid/:uid
func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Response {
uid := macaron.Params(c.Req)[":uid"]
uid := web.Params(c.Req)[":uid"]
if uid == "" {
return response.Error(400, "Missing datasource uid", nil)
@ -165,7 +165,7 @@ func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Respo
}
func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Response {
name := macaron.Params(c.Req)[":name"]
name := web.Params(c.Req)[":name"]
if name == "" {
return response.Error(400, "Missing valid datasource name", nil)
@ -334,7 +334,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: macaron.Params(c.Req)[":name"], OrgId: c.OrgId}
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
if err := bus.Dispatch(&query); err != nil {
if errors.Is(err, models.ErrDataSourceNotFound) {
@ -349,7 +349,7 @@ func GetDataSourceByName(c *models.ReqContext) response.Response {
// Get /api/datasources/id/:name
func GetDataSourceIdByName(c *models.ReqContext) response.Response {
query := models.GetDataSourceQuery{Name: macaron.Params(c.Req)[":name"], OrgId: c.OrgId}
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
if err := bus.Dispatch(&query); err != nil {
if errors.Is(err, models.ErrDataSourceNotFound) {
@ -397,7 +397,7 @@ func (hs *HTTPServer) CallDatasourceResource(c *models.ReqContext) {
PluginID: plugin.Id,
DataSourceInstanceSettings: dsInstanceSettings,
}
hs.BackendPluginManager.CallResource(pCtx, c, macaron.Params(c.Req)["*"])
hs.BackendPluginManager.CallResource(pCtx, c, web.Params(c.Req)["*"])
}
func convertModelToDtos(ds *models.DataSource) dtos.DataSource {