Chore: replace macaron with web package (#40136)
* replace macaron with web package * add web.go
This commit is contained in:
+4
-4
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/search"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func ValidateOrgAlert(c *models.ReqContext) {
|
||||
@@ -258,7 +258,7 @@ func GetAlertNotificationByID(c *models.ReqContext) response.Response {
|
||||
func GetAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
query := &models.GetAlertNotificationsWithUidQuery{
|
||||
OrgId: c.OrgId,
|
||||
Uid: macaron.Params(c.Req)[":uid"],
|
||||
Uid: web.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if query.Uid == "" {
|
||||
@@ -318,7 +318,7 @@ func (hs *HTTPServer) UpdateAlertNotification(c *models.ReqContext, cmd models.U
|
||||
|
||||
func (hs *HTTPServer) UpdateAlertNotificationByUID(c *models.ReqContext, cmd models.UpdateAlertNotificationWithUidCommand) response.Response {
|
||||
cmd.OrgId = c.OrgId
|
||||
cmd.Uid = macaron.Params(c.Req)[":uid"]
|
||||
cmd.Uid = web.Params(c.Req)[":uid"]
|
||||
|
||||
err := hs.fillWithSecureSettingsDataByUID(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
@@ -419,7 +419,7 @@ func DeleteAlertNotification(c *models.ReqContext) response.Response {
|
||||
func DeleteAlertNotificationByUID(c *models.ReqContext) response.Response {
|
||||
cmd := models.DeleteAlertNotificationWithUidCommand{
|
||||
OrgId: c.OrgId,
|
||||
Uid: macaron.Params(c.Req)[":uid"],
|
||||
Uid: web.Params(c.Req)[":uid"],
|
||||
}
|
||||
|
||||
if err := bus.Dispatch(&cmd); err != nil {
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var pluginProxyTransport *http.Transport
|
||||
|
||||
func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
|
||||
func (hs *HTTPServer) initAppPluginRoutes(r *web.Mux) {
|
||||
pluginProxyTransport = &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: hs.Cfg.PluginsAppsSkipVerifyTLS,
|
||||
@@ -35,7 +35,7 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
|
||||
for _, plugin := range hs.PluginManager.Apps() {
|
||||
for _, route := range plugin.Routes {
|
||||
url := util.JoinURLFragments("/api/plugin-proxy/"+plugin.Id, route.Path)
|
||||
handlers := make([]macaron.Handler, 0)
|
||||
handlers := make([]web.Handler, 0)
|
||||
handlers = append(handlers, middleware.Auth(&middleware.AuthOptions{
|
||||
ReqSignedIn: true,
|
||||
}))
|
||||
@@ -56,9 +56,9 @@ func (hs *HTTPServer) initAppPluginRoutes(r *macaron.Macaron) {
|
||||
}
|
||||
}
|
||||
|
||||
func AppPluginRoute(route *plugins.AppPluginRoute, appID string, hs *HTTPServer) macaron.Handler {
|
||||
func AppPluginRoute(route *plugins.AppPluginRoute, appID string, hs *HTTPServer) web.Handler {
|
||||
return func(c *models.ReqContext) {
|
||||
path := macaron.Params(c.Req)["*"]
|
||||
path := web.Params(c.Req)["*"]
|
||||
|
||||
proxy := pluginproxy.NewApiPluginProxy(c, path, route, appID, hs.Cfg, hs.EncryptionService)
|
||||
proxy.Transport = pluginProxyTransport
|
||||
|
||||
@@ -23,8 +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"
|
||||
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
gocache "github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
@@ -78,7 +77,7 @@ type CacheServer struct {
|
||||
var validMD5 = regexp.MustCompile("^[a-fA-F0-9]{32}$")
|
||||
|
||||
func (a *CacheServer) Handler(ctx *models.ReqContext) {
|
||||
hash := macaron.Params(ctx.Req)[":hash"]
|
||||
hash := web.Params(ctx.Req)[":hash"]
|
||||
|
||||
if len(hash) != 32 || !validMD5.MatchString(hash) {
|
||||
ctx.JsonApiErr(404, "Avatar not found", nil)
|
||||
|
||||
@@ -12,9 +12,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/searchusers"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/api/routing"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
@@ -29,6 +26,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func loggedInUserScenario(t *testing.T, desc string, url string, fn scenarioFunc) {
|
||||
@@ -148,12 +147,12 @@ func (sc *scenarioContext) fakeReqNoAssertionsWithCookie(method, url string, coo
|
||||
type scenarioContext struct {
|
||||
t *testing.T
|
||||
cfg *setting.Cfg
|
||||
m *macaron.Macaron
|
||||
m *web.Mux
|
||||
context *models.ReqContext
|
||||
resp *httptest.ResponseRecorder
|
||||
handlerFunc handlerFunc
|
||||
handlerFuncCtx handlerFuncCtx
|
||||
defaultHandler macaron.Handler
|
||||
defaultHandler web.Handler
|
||||
req *http.Request
|
||||
url string
|
||||
userAuthTokenService *auth.FakeUserAuthTokenService
|
||||
@@ -200,8 +199,8 @@ func setupScenarioContext(t *testing.T, url string) *scenarioContext {
|
||||
require.NoError(t, err)
|
||||
require.Truef(t, exists, "Views should be in %q", viewsPath)
|
||||
|
||||
sc.m = macaron.New()
|
||||
sc.m.UseMiddleware(macaron.Renderer(viewsPath, "[[", "]]"))
|
||||
sc.m = web.New()
|
||||
sc.m.UseMiddleware(web.Renderer(viewsPath, "[[", "]]"))
|
||||
sc.m.Use(getContextHandler(t, cfg).Middleware)
|
||||
|
||||
return sc
|
||||
|
||||
@@ -8,19 +8,18 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"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"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/components/dashdiffs"
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/alerting"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -71,7 +70,7 @@ func (hs *HTTPServer) TrimDashboard(c *models.ReqContext, cmd models.TrimDashboa
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetDashboard(c *models.ReqContext) response.Response {
|
||||
uid := macaron.Params(c.Req)[":uid"]
|
||||
uid := web.Params(c.Req)[":uid"]
|
||||
dash, rsp := getDashboardHelper(c.Req.Context(), c.OrgId, 0, uid)
|
||||
if rsp != nil {
|
||||
return rsp
|
||||
@@ -215,7 +214,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: macaron.Params(c.Req)[":slug"]}
|
||||
query := models.GetDashboardsBySlugQuery{OrgId: c.OrgId, Slug: web.Params(c.Req)[":slug"]}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
return response.Error(500, "Failed to retrieve dashboards by slug", err)
|
||||
@@ -233,7 +232,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, macaron.Params(c.Req)[":uid"])
|
||||
dash, rsp := getDashboardHelper(c.Req.Context(), c.OrgId, 0, web.Params(c.Req)[":uid"])
|
||||
if rsp != nil {
|
||||
return rsp
|
||||
}
|
||||
|
||||
@@ -16,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var client = &http.Client{
|
||||
@@ -146,7 +146,7 @@ func CreateDashboardSnapshot(c *models.ReqContext, cmd models.CreateDashboardSna
|
||||
|
||||
// GET /api/snapshots/:key
|
||||
func GetDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
key := macaron.Params(c.Req)[":key"]
|
||||
key := web.Params(c.Req)[":key"]
|
||||
if len(key) == 0 {
|
||||
return response.Error(404, "Snapshot not found", nil)
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func deleteExternalDashboardSnapshot(externalUrl string) error {
|
||||
|
||||
// GET /api/snapshots-delete/:deleteKey
|
||||
func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response {
|
||||
key := macaron.Params(c.Req)[":deleteKey"]
|
||||
key := web.Params(c.Req)[":deleteKey"]
|
||||
if len(key) == 0 {
|
||||
return response.Error(404, "Snapshot not found", nil)
|
||||
}
|
||||
@@ -247,7 +247,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
|
||||
|
||||
// DELETE /api/snapshots/:key
|
||||
func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
|
||||
key := macaron.Params(c.Req)[":key"]
|
||||
key := web.Params(c.Req)[":key"]
|
||||
if len(key) == 0 {
|
||||
return response.Error(404, "Snapshot not found", nil)
|
||||
}
|
||||
|
||||
@@ -26,15 +26,15 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func TestGetHomeDashboard(t *testing.T) {
|
||||
httpReq, err := http.NewRequest(http.MethodGet, "", nil)
|
||||
require.NoError(t, err)
|
||||
req := &models.ReqContext{SignedInUser: &models.SignedInUser{}, Context: &macaron.Context{Req: httpReq}}
|
||||
req := &models.ReqContext{SignedInUser: &models.SignedInUser{}, Context: &web.Context{Req: httpReq}}
|
||||
cfg := setting.NewCfg()
|
||||
cfg.StaticRootPath = "../../public/"
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+5
-5
@@ -13,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetFolders(c *models.ReqContext) response.Response {
|
||||
@@ -39,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(), macaron.Params(c.Req)[":uid"])
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), web.Params(c.Req)[":uid"])
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
@@ -79,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(), macaron.Params(c.Req)[":uid"], &cmd)
|
||||
err := s.UpdateFolder(c.Req.Context(), web.Params(c.Req)[":uid"], &cmd)
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
@@ -90,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.Req.Context(), c.SignedInUser, macaron.Params(c.Req)[":uid"])
|
||||
err := hs.LibraryElementService.DeleteLibraryElementsInFolder(c.Req.Context(), c.SignedInUser, web.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)
|
||||
@@ -98,7 +98,7 @@ func (hs *HTTPServer) DeleteFolder(c *models.ReqContext) response.Response { //
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
f, err := s.DeleteFolder(c.Req.Context(), macaron.Params(c.Req)[":uid"], c.QueryBool("forceDeleteRules"))
|
||||
f, err := s.DeleteFolder(c.Req.Context(), web.Params(c.Req)[":uid"], c.QueryBool("forceDeleteRules"))
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/apierrors"
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
@@ -13,11 +11,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
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(), macaron.Params(c.Req)[":uid"])
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), web.Params(c.Req)[":uid"])
|
||||
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
@@ -65,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(), macaron.Params(c.Req)[":uid"])
|
||||
folder, err := s.GetFolderByUID(c.Req.Context(), web.Params(c.Req)[":uid"])
|
||||
if err != nil {
|
||||
return apierrors.ToFolderErrorResponse(err)
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager"
|
||||
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||
@@ -18,9 +14,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func setupTestEnvironment(t *testing.T, cfg *setting.Cfg) (*macaron.Macaron, *HTTPServer) {
|
||||
func setupTestEnvironment(t *testing.T, cfg *setting.Cfg) (*web.Mux, *HTTPServer) {
|
||||
t.Helper()
|
||||
sqlstore.InitTestDB(t)
|
||||
|
||||
@@ -53,9 +52,9 @@ func setupTestEnvironment(t *testing.T, cfg *setting.Cfg) (*macaron.Macaron, *HT
|
||||
AccessControl: accesscontrolmock.New().WithDisabled(),
|
||||
}
|
||||
|
||||
m := macaron.New()
|
||||
m := web.New()
|
||||
m.Use(getContextHandler(t, cfg).Middleware)
|
||||
m.UseMiddleware(macaron.Renderer(filepath.Join(setting.StaticRootPath, "views"), "[[", "]]"))
|
||||
m.UseMiddleware(web.Renderer(filepath.Join(setting.StaticRootPath, "views"), "[[", "]]"))
|
||||
m.Get("/api/frontend/settings/", hs.GetFrontendSettings)
|
||||
|
||||
return m, hs
|
||||
|
||||
@@ -10,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var grafanaComProxyTransport = &http.Transport{
|
||||
@@ -42,7 +42,7 @@ func ReverseProxyGnetReq(proxyPath string) *httputil.ReverseProxy {
|
||||
}
|
||||
|
||||
func ProxyGnetRequest(c *models.ReqContext) {
|
||||
proxyPath := macaron.Params(c.Req)["*"]
|
||||
proxyPath := web.Params(c.Req)["*"]
|
||||
proxy := ReverseProxyGnetReq(proxyPath)
|
||||
proxy.Transport = grafanaComProxyTransport
|
||||
proxy.ServeHTTP(c.Resp, c.Req)
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/require"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func TestHealthAPI_Version(t *testing.T) {
|
||||
@@ -167,13 +167,13 @@ func TestHealthAPI_DatabaseHealthCached(t *testing.T) {
|
||||
require.True(t, healthy.(bool))
|
||||
}
|
||||
|
||||
func setupHealthAPITestEnvironment(t *testing.T, cbs ...func(*setting.Cfg)) (*macaron.Macaron, *HTTPServer) {
|
||||
func setupHealthAPITestEnvironment(t *testing.T, cbs ...func(*setting.Cfg)) (*web.Mux, *HTTPServer) {
|
||||
t.Helper()
|
||||
|
||||
bus.ClearBusHandlers()
|
||||
t.Cleanup(bus.ClearBusHandlers)
|
||||
|
||||
m := macaron.New()
|
||||
m := web.New()
|
||||
cfg := setting.NewCfg()
|
||||
for _, cb := range cbs {
|
||||
cb(cfg)
|
||||
|
||||
+20
-20
@@ -57,17 +57,17 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb"
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
type HTTPServer struct {
|
||||
log log.Logger
|
||||
macaron *macaron.Macaron
|
||||
web *web.Mux
|
||||
context context.Context
|
||||
httpSrv *http.Server
|
||||
middlewares []macaron.Handler
|
||||
middlewares []web.Handler
|
||||
|
||||
PluginContextProvider *plugincontext.Provider
|
||||
RouteRegister routing.RouteRegister
|
||||
@@ -136,8 +136,8 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
||||
socialService social.Service, oauthTokenService oauthtoken.OAuthTokenService,
|
||||
encryptionService encryption.Service, searchUsersService searchusers.Service,
|
||||
dataSourcesService *datasources.Service) (*HTTPServer, error) {
|
||||
macaron.Env = cfg.Env
|
||||
m := macaron.New()
|
||||
web.Env = cfg.Env
|
||||
m := web.New()
|
||||
|
||||
hs := &HTTPServer{
|
||||
Cfg: cfg,
|
||||
@@ -177,7 +177,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
||||
tracingService: tracingService,
|
||||
internalMetricsSvc: internalMetricsSvc,
|
||||
log: log.New("http.server"),
|
||||
macaron: m,
|
||||
web: m,
|
||||
Listener: opts.Listener,
|
||||
SocialService: socialService,
|
||||
OAuthTokenService: oauthTokenService,
|
||||
@@ -196,7 +196,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
|
||||
return hs, nil
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) AddMiddleware(middleware macaron.Handler) {
|
||||
func (hs *HTTPServer) AddMiddleware(middleware web.Handler) {
|
||||
hs.middlewares = append(hs.middlewares, middleware)
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
|
||||
host := strings.TrimSuffix(strings.TrimPrefix(hs.Cfg.HTTPAddr, "["), "]")
|
||||
hs.httpSrv = &http.Server{
|
||||
Addr: net.JoinHostPort(host, hs.Cfg.HTTPPort),
|
||||
Handler: hs.macaron,
|
||||
Handler: hs.web,
|
||||
ReadTimeout: hs.Cfg.ReadTimeout,
|
||||
}
|
||||
switch hs.Cfg.Protocol {
|
||||
@@ -386,15 +386,15 @@ func (hs *HTTPServer) applyRoutes() {
|
||||
// start with middlewares & static routes
|
||||
hs.addMiddlewaresAndStaticRoutes()
|
||||
// then add view routes & api routes
|
||||
hs.RouteRegister.Register(hs.macaron)
|
||||
hs.RouteRegister.Register(hs.web)
|
||||
// then custom app proxy routes
|
||||
hs.initAppPluginRoutes(hs.macaron)
|
||||
hs.initAppPluginRoutes(hs.web)
|
||||
// lastly not found route
|
||||
hs.macaron.NotFound(middleware.ReqSignedIn, hs.NotFoundHandler)
|
||||
hs.web.NotFound(middleware.ReqSignedIn, hs.NotFoundHandler)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
m := hs.macaron
|
||||
m := hs.web
|
||||
|
||||
m.Use(middleware.RequestTracing())
|
||||
|
||||
@@ -420,7 +420,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
m.SetURLPrefix(hs.Cfg.AppSubURL)
|
||||
}
|
||||
|
||||
m.UseMiddleware(macaron.Renderer(filepath.Join(hs.Cfg.StaticRootPath, "views"), "[[", "]]"))
|
||||
m.UseMiddleware(web.Renderer(filepath.Join(hs.Cfg.StaticRootPath, "views"), "[[", "]]"))
|
||||
|
||||
// These endpoints are used for monitoring the Grafana instance
|
||||
// and should not be redirected or rejected.
|
||||
@@ -444,7 +444,7 @@ func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
|
||||
}
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) {
|
||||
func (hs *HTTPServer) metricsEndpoint(ctx *web.Context) {
|
||||
if !hs.Cfg.MetricsEndpointEnabled {
|
||||
return
|
||||
}
|
||||
@@ -464,7 +464,7 @@ func (hs *HTTPServer) metricsEndpoint(ctx *macaron.Context) {
|
||||
}
|
||||
|
||||
// healthzHandler always return 200 - Ok if Grafana's web server is running
|
||||
func (hs *HTTPServer) healthzHandler(ctx *macaron.Context) {
|
||||
func (hs *HTTPServer) healthzHandler(ctx *web.Context) {
|
||||
notHeadOrGet := ctx.Req.Method != http.MethodGet && ctx.Req.Method != http.MethodHead
|
||||
if notHeadOrGet || ctx.Req.URL.Path != "/healthz" {
|
||||
return
|
||||
@@ -480,7 +480,7 @@ func (hs *HTTPServer) healthzHandler(ctx *macaron.Context) {
|
||||
// apiHealthHandler will return ok if Grafana's web server is running and it
|
||||
// can access the database. If the database cannot be accessed it will return
|
||||
// http status code 503.
|
||||
func (hs *HTTPServer) apiHealthHandler(ctx *macaron.Context) {
|
||||
func (hs *HTTPServer) apiHealthHandler(ctx *web.Context) {
|
||||
notHeadOrGet := ctx.Req.Method != http.MethodGet && ctx.Req.Method != http.MethodHead
|
||||
if notHeadOrGet || ctx.Req.URL.Path != "/api/health" {
|
||||
return
|
||||
@@ -513,19 +513,19 @@ func (hs *HTTPServer) apiHealthHandler(ctx *macaron.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) mapStatic(m *macaron.Macaron, rootDir string, dir string, prefix string) {
|
||||
headers := func(c *macaron.Context) {
|
||||
func (hs *HTTPServer) mapStatic(m *web.Mux, rootDir string, dir string, prefix string) {
|
||||
headers := func(c *web.Context) {
|
||||
c.Resp.Header().Set("Cache-Control", "public, max-age=3600")
|
||||
}
|
||||
|
||||
if prefix == "public/build" {
|
||||
headers = func(c *macaron.Context) {
|
||||
headers = func(c *web.Context) {
|
||||
c.Resp.Header().Set("Cache-Control", "public, max-age=31536000")
|
||||
}
|
||||
}
|
||||
|
||||
if hs.Cfg.Env == setting.Dev {
|
||||
headers = func(c *macaron.Context) {
|
||||
headers = func(c *web.Context) {
|
||||
c.Resp.Header().Set("Cache-Control", "max-age=0, must-revalidate, no-cache")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -239,7 +239,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
|
||||
ldap := newLDAP(ldapConfig.Servers)
|
||||
|
||||
username := macaron.Params(c.Req)[":username"]
|
||||
username := web.Params(c.Req)[":username"]
|
||||
|
||||
if len(username) == 0 {
|
||||
return response.Error(http.StatusBadRequest, "Validation error. You must specify an username", nil)
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -173,7 +173,7 @@ func (hs *HTTPServer) LoginAPIPing(c *models.ReqContext) response.Response {
|
||||
|
||||
func (hs *HTTPServer) LoginPost(c *models.ReqContext) response.Response {
|
||||
cmd := dtos.LoginCommand{}
|
||||
if err := macaron.Bind(c.Req, &cmd); err != nil {
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad login data", err)
|
||||
}
|
||||
authModule := ""
|
||||
|
||||
@@ -11,9 +11,6 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
@@ -22,6 +19,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/middleware/cookies"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -42,7 +41,7 @@ func (hs *HTTPServer) OAuthLogin(ctx *models.ReqContext) {
|
||||
loginInfo := models.LoginInfo{
|
||||
AuthModule: "oauth",
|
||||
}
|
||||
name := macaron.Params(ctx.Req)[":name"]
|
||||
name := web.Params(ctx.Req)[":name"]
|
||||
loginInfo.AuthModule = name
|
||||
provider := hs.SocialService.GetOAuthInfoProvider(name)
|
||||
if provider == nil {
|
||||
|
||||
+2
-2
@@ -10,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
// GET /api/org
|
||||
@@ -25,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(macaron.Params(c.Req)[":name"])
|
||||
org, err := hs.SQLStore.GetOrgByName(web.Params(c.Req)[":name"])
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrOrgNotFound) {
|
||||
return response.Error(404, "Organization not found", err)
|
||||
|
||||
@@ -12,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func GetPendingOrgInvites(c *models.ReqContext) response.Response {
|
||||
@@ -132,7 +132,7 @@ func inviteExistingUserToOrg(c *models.ReqContext, user *models.User, inviteDto
|
||||
}
|
||||
|
||||
func RevokeInvite(c *models.ReqContext) response.Response {
|
||||
if ok, rsp := updateTempUserStatus(macaron.Params(c.Req)[":code"], models.TmpUserRevoked); !ok {
|
||||
if ok, rsp := updateTempUserStatus(web.Params(c.Req)[":code"], models.TmpUserRevoked); !ok {
|
||||
return rsp
|
||||
}
|
||||
|
||||
@@ -143,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: macaron.Params(c.Req)[":code"]}
|
||||
query := models.GetTempUserByCodeQuery{Code: web.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)
|
||||
|
||||
@@ -22,10 +22,10 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/encryption/ossencryption"
|
||||
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/oauth2"
|
||||
"gopkg.in/macaron.v1"
|
||||
)
|
||||
|
||||
func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
@@ -114,7 +114,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", "http://localhost/asd", nil)
|
||||
require.NoError(t, err)
|
||||
ctx := &models.ReqContext{
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
return ctx, req
|
||||
@@ -255,7 +255,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", "http://localhost/asd", nil)
|
||||
require.NoError(t, err)
|
||||
ctx := &models.ReqContext{
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ func TestDataSourceProxy_routeRule(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
ctx := &models.ReqContext{
|
||||
SignedInUser: &models.SignedInUser{UserId: 1},
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
}
|
||||
mockAuthToken := mockOAuthTokenService{
|
||||
token: &oauth2.Token{
|
||||
@@ -600,7 +600,7 @@ func TestDataSourceProxy_requestHandling(t *testing.T) {
|
||||
|
||||
ds := &models.DataSource{Url: backend.URL, Type: models.DS_GRAPHITE}
|
||||
|
||||
responseWriter := macaron.NewResponseWriter("GET", httptest.NewRecorder())
|
||||
responseWriter := web.NewResponseWriter("GET", httptest.NewRecorder())
|
||||
|
||||
// XXX: Really unsure why, but setting headers within the HTTP handler function doesn't stick,
|
||||
// so doing it here instead
|
||||
@@ -612,7 +612,7 @@ func TestDataSourceProxy_requestHandling(t *testing.T) {
|
||||
|
||||
return &models.ReqContext{
|
||||
SignedInUser: &models.SignedInUser{},
|
||||
Context: &macaron.Context{
|
||||
Context: &web.Context{
|
||||
Req: httptest.NewRequest("GET", "/render", nil),
|
||||
Resp: responseWriter,
|
||||
},
|
||||
@@ -694,7 +694,7 @@ func TestDataSourceProxy_requestHandling(t *testing.T) {
|
||||
|
||||
func TestNewDataSourceProxy_InvalidURL(t *testing.T) {
|
||||
ctx := models.ReqContext{
|
||||
Context: &macaron.Context{},
|
||||
Context: &web.Context{},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
ds := models.DataSource{
|
||||
@@ -711,7 +711,7 @@ func TestNewDataSourceProxy_InvalidURL(t *testing.T) {
|
||||
|
||||
func TestNewDataSourceProxy_ProtocolLessURL(t *testing.T) {
|
||||
ctx := models.ReqContext{
|
||||
Context: &macaron.Context{},
|
||||
Context: &web.Context{},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
ds := models.DataSource{
|
||||
@@ -730,7 +730,7 @@ func TestNewDataSourceProxy_ProtocolLessURL(t *testing.T) {
|
||||
// Test wth MSSQL type data sources.
|
||||
func TestNewDataSourceProxy_MSSQL(t *testing.T) {
|
||||
ctx := models.ReqContext{
|
||||
Context: &macaron.Context{},
|
||||
Context: &web.Context{},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_EDITOR},
|
||||
}
|
||||
tcs := []struct {
|
||||
@@ -939,7 +939,7 @@ func Test_PathCheck(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", "http://localhost/asd", nil)
|
||||
require.NoError(t, err)
|
||||
ctx := &models.ReqContext{
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
SignedInUser: &models.SignedInUser{OrgRole: models.ROLE_VIEWER},
|
||||
}
|
||||
return ctx, req
|
||||
|
||||
+14
-14
@@ -17,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) GetPluginList(c *models.ReqContext) response.Response {
|
||||
@@ -101,7 +101,7 @@ func (hs *HTTPServer) GetPluginList(c *models.ReqContext) response.Response {
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Response {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
def := hs.PluginManager.GetPlugin(pluginID)
|
||||
if def == nil {
|
||||
@@ -146,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 := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
if app := hs.PluginManager.GetApp(pluginID); app == nil {
|
||||
return response.Error(404, "Plugin not installed", nil)
|
||||
@@ -162,7 +162,7 @@ func (hs *HTTPServer) UpdatePluginSetting(c *models.ReqContext, cmd models.Updat
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginDashboards(c *models.ReqContext) response.Response {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
list, err := hs.PluginManager.GetPluginDashboards(c.OrgId, pluginID)
|
||||
if err != nil {
|
||||
@@ -178,8 +178,8 @@ func (hs *HTTPServer) GetPluginDashboards(c *models.ReqContext) response.Respons
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginMarkdown(c *models.ReqContext) response.Response {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
name := macaron.Params(c.Req)[":name"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
name := web.Params(c.Req)[":name"]
|
||||
|
||||
content, err := hs.PluginManager.GetPluginMarkdown(pluginID, name)
|
||||
if err != nil {
|
||||
@@ -241,7 +241,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 := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||
if plugin == nil {
|
||||
return response.Error(404, "Plugin not found", nil)
|
||||
@@ -262,14 +262,14 @@ func (hs *HTTPServer) CollectPluginMetrics(c *models.ReqContext) response.Respon
|
||||
//
|
||||
// /public/plugins/:pluginId/*
|
||||
func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||
if plugin == nil {
|
||||
c.JsonApiErr(404, "Plugin not found", nil)
|
||||
return
|
||||
}
|
||||
|
||||
requestedFile := filepath.Clean(macaron.Params(c.Req)["*"])
|
||||
requestedFile := filepath.Clean(web.Params(c.Req)["*"])
|
||||
pluginFilePath := filepath.Join(plugin.PluginDir, requestedFile)
|
||||
|
||||
if !plugin.IncludedInSignature(requestedFile) {
|
||||
@@ -313,7 +313,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 := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
pCtx, found, err := hs.PluginContextProvider.Get(pluginID, "", c.SignedInUser, false)
|
||||
if err != nil {
|
||||
@@ -355,7 +355,7 @@ func (hs *HTTPServer) CheckHealth(c *models.ReqContext) response.Response {
|
||||
//
|
||||
// /api/plugins/:pluginId/resources/*
|
||||
func (hs *HTTPServer) CallResource(c *models.ReqContext) {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
pCtx, found, err := hs.PluginContextProvider.Get(pluginID, "", c.SignedInUser, false)
|
||||
if err != nil {
|
||||
@@ -366,7 +366,7 @@ func (hs *HTTPServer) CallResource(c *models.ReqContext) {
|
||||
c.JsonApiErr(404, "Plugin not found", nil)
|
||||
return
|
||||
}
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, macaron.Params(c.Req)["*"])
|
||||
hs.BackendPluginManager.CallResource(pCtx, c, web.Params(c.Req)["*"])
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) GetPluginErrorsList(_ *models.ReqContext) response.Response {
|
||||
@@ -374,7 +374,7 @@ func (hs *HTTPServer) GetPluginErrorsList(_ *models.ReqContext) response.Respons
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) InstallPlugin(c *models.ReqContext, dto dtos.InstallPluginCommand) response.Response {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
err := hs.PluginManager.Install(c.Req.Context(), pluginID, dto.Version)
|
||||
if err != nil {
|
||||
@@ -405,7 +405,7 @@ func (hs *HTTPServer) InstallPlugin(c *models.ReqContext, dto dtos.InstallPlugin
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) UninstallPlugin(c *models.ReqContext) response.Response {
|
||||
pluginID := macaron.Params(c.Req)[":pluginId"]
|
||||
pluginID := web.Params(c.Req)[":pluginId"]
|
||||
|
||||
err := hs.PluginManager.Uninstall(c.Req.Context(), pluginID)
|
||||
if err != nil {
|
||||
|
||||
+3
-3
@@ -5,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func GetOrgQuotas(c *models.ReqContext) response.Response {
|
||||
@@ -26,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 = macaron.Params(c.Req)[":target"]
|
||||
cmd.Target = web.Params(c.Req)[":target"]
|
||||
|
||||
if _, ok := setting.Quota.Org.ToMap()[cmd.Target]; !ok {
|
||||
return response.Error(404, "Invalid quota target", nil)
|
||||
@@ -56,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 = macaron.Params(c.Req)[":target"]
|
||||
cmd.Target = web.Params(c.Req)[":target"]
|
||||
|
||||
if _, ok := setting.Quota.User.ToMap()[cmd.Target]; !ok {
|
||||
return response.Error(404, "Invalid quota target", nil)
|
||||
|
||||
+2
-2
@@ -10,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
|
||||
@@ -59,7 +59,7 @@ func (hs *HTTPServer) RenderToPng(c *models.ReqContext) {
|
||||
OrgID: c.OrgId,
|
||||
UserID: c.UserId,
|
||||
OrgRole: c.OrgRole,
|
||||
Path: macaron.Params(c.Req)["*"] + queryParams,
|
||||
Path: web.Params(c.Req)["*"] + queryParams,
|
||||
Timezone: queryReader.Get("tz", ""),
|
||||
Encoding: queryReader.Get("encoding", ""),
|
||||
ConcurrentLimit: hs.Cfg.RendererConcurrentRequestLimit,
|
||||
|
||||
@@ -6,41 +6,41 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
type Router interface {
|
||||
Handle(method, pattern string, handlers []macaron.Handler)
|
||||
Get(pattern string, handlers ...macaron.Handler)
|
||||
Handle(method, pattern string, handlers []web.Handler)
|
||||
Get(pattern string, handlers ...web.Handler)
|
||||
}
|
||||
|
||||
// RouteRegister allows you to add routes and macaron.Handlers
|
||||
// RouteRegister allows you to add routes and web.Handlers
|
||||
// that the web server should serve.
|
||||
type RouteRegister interface {
|
||||
// Get adds a list of handlers to a given route with a GET HTTP verb
|
||||
Get(string, ...macaron.Handler)
|
||||
Get(string, ...web.Handler)
|
||||
|
||||
// Post adds a list of handlers to a given route with a POST HTTP verb
|
||||
Post(string, ...macaron.Handler)
|
||||
Post(string, ...web.Handler)
|
||||
|
||||
// Delete adds a list of handlers to a given route with a DELETE HTTP verb
|
||||
Delete(string, ...macaron.Handler)
|
||||
Delete(string, ...web.Handler)
|
||||
|
||||
// Put adds a list of handlers to a given route with a PUT HTTP verb
|
||||
Put(string, ...macaron.Handler)
|
||||
Put(string, ...web.Handler)
|
||||
|
||||
// Patch adds a list of handlers to a given route with a PATCH HTTP verb
|
||||
Patch(string, ...macaron.Handler)
|
||||
Patch(string, ...web.Handler)
|
||||
|
||||
// Any adds a list of handlers to a given route with any HTTP verb
|
||||
Any(string, ...macaron.Handler)
|
||||
Any(string, ...web.Handler)
|
||||
|
||||
// Group allows you to pass a function that can add multiple routes
|
||||
// with a shared prefix route.
|
||||
Group(string, func(RouteRegister), ...macaron.Handler)
|
||||
Group(string, func(RouteRegister), ...web.Handler)
|
||||
|
||||
// Insert adds more routes to an existing Group.
|
||||
Insert(string, func(RouteRegister), ...macaron.Handler)
|
||||
Insert(string, func(RouteRegister), ...web.Handler)
|
||||
|
||||
// Register iterates over all routes added to the RouteRegister
|
||||
// and add them to the `Router` pass as an parameter.
|
||||
@@ -50,7 +50,7 @@ type RouteRegister interface {
|
||||
Reset()
|
||||
}
|
||||
|
||||
type RegisterNamedMiddleware func(name string) macaron.Handler
|
||||
type RegisterNamedMiddleware func(name string) web.Handler
|
||||
|
||||
func ProvideRegister(cfg *setting.Cfg) *RouteRegisterImpl {
|
||||
return NewRouteRegister(middleware.ProvideRouteOperationName, middleware.RequestMetrics(cfg))
|
||||
@@ -61,7 +61,7 @@ func NewRouteRegister(namedMiddlewares ...RegisterNamedMiddleware) *RouteRegiste
|
||||
return &RouteRegisterImpl{
|
||||
prefix: "",
|
||||
routes: []route{},
|
||||
subfixHandlers: []macaron.Handler{},
|
||||
subfixHandlers: []web.Handler{},
|
||||
namedMiddlewares: namedMiddlewares,
|
||||
}
|
||||
}
|
||||
@@ -69,12 +69,12 @@ func NewRouteRegister(namedMiddlewares ...RegisterNamedMiddleware) *RouteRegiste
|
||||
type route struct {
|
||||
method string
|
||||
pattern string
|
||||
handlers []macaron.Handler
|
||||
handlers []web.Handler
|
||||
}
|
||||
|
||||
type RouteRegisterImpl struct {
|
||||
prefix string
|
||||
subfixHandlers []macaron.Handler
|
||||
subfixHandlers []web.Handler
|
||||
namedMiddlewares []RegisterNamedMiddleware
|
||||
routes []route
|
||||
groups []*RouteRegisterImpl
|
||||
@@ -90,7 +90,7 @@ func (rr *RouteRegisterImpl) Reset() {
|
||||
rr.subfixHandlers = nil
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Insert(pattern string, fn func(RouteRegister), handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Insert(pattern string, fn func(RouteRegister), handlers ...web.Handler) {
|
||||
// loop over all groups at current level
|
||||
for _, g := range rr.groups {
|
||||
// apply routes if the prefix matches the pattern
|
||||
@@ -106,7 +106,7 @@ func (rr *RouteRegisterImpl) Insert(pattern string, fn func(RouteRegister), hand
|
||||
}
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Group(pattern string, fn func(rr RouteRegister), handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Group(pattern string, fn func(rr RouteRegister), handlers ...web.Handler) {
|
||||
group := &RouteRegisterImpl{
|
||||
prefix: rr.prefix + pattern,
|
||||
subfixHandlers: append(rr.subfixHandlers, handlers...),
|
||||
@@ -135,8 +135,8 @@ func (rr *RouteRegisterImpl) Register(router Router) {
|
||||
}
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) route(pattern, method string, handlers ...macaron.Handler) {
|
||||
h := make([]macaron.Handler, 0)
|
||||
func (rr *RouteRegisterImpl) route(pattern, method string, handlers ...web.Handler) {
|
||||
h := make([]web.Handler, 0)
|
||||
fullPattern := rr.prefix + pattern
|
||||
|
||||
for _, fn := range rr.namedMiddlewares {
|
||||
@@ -159,26 +159,26 @@ func (rr *RouteRegisterImpl) route(pattern, method string, handlers ...macaron.H
|
||||
})
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Get(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Get(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, http.MethodGet, handlers...)
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Post(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Post(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, http.MethodPost, handlers...)
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Delete(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Delete(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, http.MethodDelete, handlers...)
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Put(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Put(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, http.MethodPut, handlers...)
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Patch(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Patch(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, http.MethodPatch, handlers...)
|
||||
}
|
||||
|
||||
func (rr *RouteRegisterImpl) Any(pattern string, handlers ...macaron.Handler) {
|
||||
func (rr *RouteRegisterImpl) Any(pattern string, handlers ...web.Handler) {
|
||||
rr.route(pattern, "*", handlers...)
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
type fakeRouter struct {
|
||||
route []route
|
||||
}
|
||||
|
||||
func (fr *fakeRouter) Handle(method, pattern string, handlers []macaron.Handler) {
|
||||
func (fr *fakeRouter) Handle(method, pattern string, handlers []web.Handler) {
|
||||
fr.route = append(fr.route, route{
|
||||
pattern: pattern,
|
||||
method: method,
|
||||
@@ -20,7 +20,7 @@ func (fr *fakeRouter) Handle(method, pattern string, handlers []macaron.Handler)
|
||||
})
|
||||
}
|
||||
|
||||
func (fr *fakeRouter) Get(pattern string, handlers ...macaron.Handler) {
|
||||
func (fr *fakeRouter) Get(pattern string, handlers ...web.Handler) {
|
||||
fr.route = append(fr.route, route{
|
||||
pattern: pattern,
|
||||
method: http.MethodGet,
|
||||
@@ -28,15 +28,15 @@ func (fr *fakeRouter) Get(pattern string, handlers ...macaron.Handler) {
|
||||
})
|
||||
}
|
||||
|
||||
func emptyHandlers(n int) []macaron.Handler {
|
||||
var res []macaron.Handler
|
||||
func emptyHandlers(n int) []web.Handler {
|
||||
var res []web.Handler
|
||||
for i := 1; n >= i; i++ {
|
||||
res = append(res, emptyHandler(strconv.Itoa(i)))
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func emptyHandler(name string) macaron.Handler {
|
||||
func emptyHandler(name string) web.Handler {
|
||||
return struct{ name string }{name: name}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ func TestNamedMiddlewareRouteRegister(t *testing.T) {
|
||||
|
||||
namedMiddlewares := map[string]bool{}
|
||||
// Setup
|
||||
rr := NewRouteRegister(func(name string) macaron.Handler {
|
||||
rr := NewRouteRegister(func(name string) web.Handler {
|
||||
namedMiddlewares[name] = true
|
||||
|
||||
return struct{ name string }{name: name}
|
||||
|
||||
@@ -3,7 +3,7 @@ package routing
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -12,7 +12,7 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func Wrap(action interface{}) macaron.Handler {
|
||||
func Wrap(action interface{}) web.Handler {
|
||||
return func(c *models.ReqContext) {
|
||||
var res response.Response
|
||||
val, err := c.Invoke(action)
|
||||
|
||||
@@ -11,7 +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"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
// createShortURL handles requests to create short URLs.
|
||||
@@ -46,7 +46,7 @@ func (hs *HTTPServer) createShortURL(c *models.ReqContext, cmd dtos.CreateShortU
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) redirectFromShortURL(c *models.ReqContext) {
|
||||
shortURLUID := macaron.Params(c.Req)[":uid"]
|
||||
shortURLUID := web.Params(c.Req)[":uid"]
|
||||
|
||||
if !util.IsValidShortUID(shortURLUID) {
|
||||
return
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"gopkg.in/macaron.v1"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
)
|
||||
|
||||
var Root string
|
||||
@@ -39,7 +39,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// StaticOptions is a struct for specifying configuration options for the macaron.Static middleware.
|
||||
// StaticOptions is a struct for specifying configuration options for the web.Static middleware.
|
||||
type StaticOptions struct {
|
||||
// Prefix is the optional prefix used to serve the static directory content
|
||||
Prefix string
|
||||
@@ -49,7 +49,7 @@ type StaticOptions struct {
|
||||
IndexFile string
|
||||
// Expires defines which user-defined function to use for producing a HTTP Expires Header
|
||||
// https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
|
||||
AddHeaders func(ctx *macaron.Context)
|
||||
AddHeaders func(ctx *web.Context)
|
||||
// FileSystem is the interface for supporting any implementation of file system.
|
||||
FileSystem http.FileSystem
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func prepareStaticOptions(dir string, options []StaticOptions) StaticOptions {
|
||||
return prepareStaticOption(dir, opt)
|
||||
}
|
||||
|
||||
func staticHandler(ctx *macaron.Context, log log.Logger, opt StaticOptions) bool {
|
||||
func staticHandler(ctx *web.Context, log log.Logger, opt StaticOptions) bool {
|
||||
if ctx.Req.Method != "GET" && ctx.Req.Method != "HEAD" {
|
||||
return false
|
||||
}
|
||||
@@ -195,11 +195,11 @@ func staticHandler(ctx *macaron.Context, log log.Logger, opt StaticOptions) bool
|
||||
}
|
||||
|
||||
// Static returns a middleware handler that serves static files in the given directory.
|
||||
func Static(directory string, staticOpt ...StaticOptions) macaron.Handler {
|
||||
func Static(directory string, staticOpt ...StaticOptions) web.Handler {
|
||||
opt := prepareStaticOptions(directory, staticOpt)
|
||||
|
||||
logger := log.New("static")
|
||||
return func(ctx *macaron.Context) {
|
||||
return func(ctx *web.Context) {
|
||||
staticHandler(ctx, logger, opt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package api
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
macaron "gopkg.in/macaron.v1"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/web"
|
||||
|
||||
"net/http"
|
||||
|
||||
@@ -126,7 +125,7 @@ func TestTeamAPIEndpoint(t *testing.T) {
|
||||
t.Run("with no real signed in user", func(t *testing.T) {
|
||||
stub := &testLogger{}
|
||||
c := &models.ReqContext{
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
SignedInUser: &models.SignedInUser{},
|
||||
Logger: stub,
|
||||
}
|
||||
@@ -142,7 +141,7 @@ func TestTeamAPIEndpoint(t *testing.T) {
|
||||
t.Run("with real signed in user", func(t *testing.T) {
|
||||
stub := &testLogger{}
|
||||
c := &models.ReqContext{
|
||||
Context: &macaron.Context{Req: req},
|
||||
Context: &web.Context{Req: req},
|
||||
SignedInUser: &models.SignedInUser{UserId: 42},
|
||||
Logger: stub,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user