Chore: Move remaining web framework code to pkg/web, remove macaron binding module (#43018)

* remove macaron binding dependency

* completely purge macaron binding

* move everything to pkg/web

* remove non-go files from pkg/web

* clean up leftovers of macaron imports

* make linter happy
This commit is contained in:
Serge Zaitsev
2021-12-13 15:56:14 +01:00
committed by GitHub
parent 1db9b1e6a9
commit f5802878f1
24 changed files with 47 additions and 1342 deletions

View File

@@ -16,8 +16,8 @@ import (
"github.com/grafana/grafana/pkg/services/serviceaccounts/tests"
"github.com/grafana/grafana/pkg/services/sqlstore"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/web"
"github.com/stretchr/testify/require"
"gopkg.in/macaron.v1"
)
var (
@@ -30,7 +30,7 @@ func TestServiceAccountsAPI_DeleteServiceAccount(t *testing.T) {
store := sqlstore.InitTestDB(t)
svcmock := tests.ServiceAccountMock{}
var requestResponse = func(server *macaron.Macaron, httpMethod, requestpath string) *httptest.ResponseRecorder {
var requestResponse = func(server *web.Mux, httpMethod, requestpath string) *httptest.ResponseRecorder {
req, err := http.NewRequest(httpMethod, requestpath, nil)
require.NoError(t, err)
recorder := httptest.NewRecorder()
@@ -92,7 +92,7 @@ func serviceAccountDeletionScenario(t *testing.T, httpMethod string, endpoint st
fn(httpMethod, endpoint, user)
}
func setupTestServer(t *testing.T, svc *tests.ServiceAccountMock, routerRegister routing.RouteRegister, acmock *accesscontrolmock.Mock) *macaron.Macaron {
func setupTestServer(t *testing.T, svc *tests.ServiceAccountMock, routerRegister routing.RouteRegister, acmock *accesscontrolmock.Mock) *web.Mux {
a := NewServiceAccountsAPI(
svc,
acmock,
@@ -100,13 +100,13 @@ func setupTestServer(t *testing.T, svc *tests.ServiceAccountMock, routerRegister
)
a.RegisterAPIEndpoints(&setting.Cfg{FeatureToggles: map[string]bool{"service-accounts": true}})
m := macaron.New()
m := web.New()
signedUser := &models.SignedInUser{
OrgId: 1,
OrgRole: models.ROLE_ADMIN,
}
m.Use(func(c *macaron.Context) {
m.Use(func(c *web.Context) {
ctx := &models.ReqContext{
Context: c,
IsSignedIn: true,