This reverts commit 280bc7f97e.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6a9c4ad56b
Коммит
ea3ff49b35
@@ -103,8 +103,6 @@ type Routes struct {
|
||||
|
||||
Jobs *mux.Router // 'api/v4/jobs'
|
||||
|
||||
DebugBar *mux.Router // 'api/v4/debugbar'
|
||||
|
||||
Preferences *mux.Router // 'api/v4/users/{user_id:[A-Za-z0-9]+}/preferences'
|
||||
|
||||
License *mux.Router // 'api/v4/license'
|
||||
@@ -237,7 +235,6 @@ func Init(srv *app.Server) (*API, error) {
|
||||
api.BaseRoutes.Public = api.BaseRoutes.APIRoot.PathPrefix("/public").Subrouter()
|
||||
api.BaseRoutes.Reactions = api.BaseRoutes.APIRoot.PathPrefix("/reactions").Subrouter()
|
||||
api.BaseRoutes.Jobs = api.BaseRoutes.APIRoot.PathPrefix("/jobs").Subrouter()
|
||||
api.BaseRoutes.DebugBar = api.BaseRoutes.APIRoot.PathPrefix("/debugbar").Subrouter()
|
||||
api.BaseRoutes.Elasticsearch = api.BaseRoutes.APIRoot.PathPrefix("/elasticsearch").Subrouter()
|
||||
api.BaseRoutes.Bleve = api.BaseRoutes.APIRoot.PathPrefix("/bleve").Subrouter()
|
||||
api.BaseRoutes.DataRetention = api.BaseRoutes.APIRoot.PathPrefix("/data_retention").Subrouter()
|
||||
@@ -301,7 +298,6 @@ func Init(srv *app.Server) (*API, error) {
|
||||
api.InitDataRetention()
|
||||
api.InitBrand()
|
||||
api.InitJob()
|
||||
api.InitDebugBar()
|
||||
api.InitCommand()
|
||||
api.InitStatus()
|
||||
api.InitWebSocket()
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package api4
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
)
|
||||
|
||||
func (api *API) InitDebugBar() {
|
||||
api.BaseRoutes.DebugBar.Handle("/systeminfo", api.APISessionRequired(getSystemInfo)).Methods("GET")
|
||||
api.BaseRoutes.DebugBar.Handle("/queryexplain", api.APISessionRequired(getQueryExplain)).Methods("POST")
|
||||
}
|
||||
|
||||
func getSystemInfo(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !c.App.Srv().DebugBar().IsEnabled() {
|
||||
c.Err = model.NewAppError("Api4.GetSystemInfo", "api.debugbar.getSystemInfo.disabled_debugbar.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
info, err := c.App.GetDebugBarInfo()
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(info); err != nil {
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func getQueryExplain(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !c.App.Srv().DebugBar().IsEnabled() {
|
||||
c.Err = model.NewAppError("Api4.GetSystemInfo", "api.debugbar.getSystemInfo.disabled_debugbar.error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
var requestBody struct {
|
||||
Query string
|
||||
Args []any
|
||||
}
|
||||
if jsonErr := json.NewDecoder(r.Body).Decode(&requestBody); jsonErr != nil {
|
||||
c.SetInvalidParamWithErr("explain_request", jsonErr)
|
||||
return
|
||||
}
|
||||
|
||||
explain, err := c.App.GetQueryExplain(requestBody.Query, requestBody.Args)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(map[string]string{"explain": explain}); err != nil {
|
||||
c.Logger.Warn("Error while writing response", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user