коммит произвёл
GitHub
родитель
565c8aa42d
Коммит
f1acdce42c
@@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
App app.AppIface
|
||||
App *app.App
|
||||
AppContext request.CTX
|
||||
Logger *mlog.Logger
|
||||
Params *Params
|
||||
|
||||
@@ -16,19 +16,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/klauspost/compress/gzhttp"
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/opentracing/opentracing-go/ext"
|
||||
spanlog "github.com/opentracing/opentracing-go/log"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/shared/i18n"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/request"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||
app_opentracing "github.com/mattermost/mattermost/server/v8/channels/app/opentracing"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/store/opentracinglayer"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/tracing"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -210,32 +204,6 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if *c.App.Config().ServiceSettings.EnableOpenTracing {
|
||||
span, ctx := tracing.StartRootSpanByContext(context.Background(), "web:ServeHTTP")
|
||||
carrier := opentracing.HTTPHeadersCarrier(r.Header)
|
||||
_ = opentracing.GlobalTracer().Inject(span.Context(), opentracing.HTTPHeaders, carrier)
|
||||
ext.HTTPMethod.Set(span, r.Method)
|
||||
ext.HTTPUrl.Set(span, c.AppContext.Path())
|
||||
ext.PeerAddress.Set(span, c.AppContext.IPAddress())
|
||||
span.SetTag("request_id", c.AppContext.RequestId())
|
||||
span.SetTag("user_agent", c.AppContext.UserAgent())
|
||||
|
||||
defer func() {
|
||||
if c.Err != nil {
|
||||
span.LogFields(spanlog.Error(c.Err))
|
||||
ext.HTTPStatusCode.Set(span, uint16(c.Err.StatusCode))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
span.Finish()
|
||||
}()
|
||||
c.AppContext = c.AppContext.WithContext(ctx)
|
||||
|
||||
tmpSrv := *c.App.Srv()
|
||||
tmpSrv.SetStore(opentracinglayer.New(c.App.Srv().Store(), ctx))
|
||||
c.App.SetServer(&tmpSrv)
|
||||
c.App = app_opentracing.NewOpenTracingAppLayer(c.App, ctx)
|
||||
}
|
||||
|
||||
var maxBytes int64
|
||||
if h.FileAPI {
|
||||
// We add a buffer of bytes.MinRead so that file sizes close to max file size
|
||||
|
||||
@@ -57,7 +57,7 @@ func CheckClientCompatibility(agentString string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func Handle404(a app.AppIface, w http.ResponseWriter, r *http.Request) {
|
||||
func Handle404(a *app.App, w http.ResponseWriter, r *http.Request) {
|
||||
err := model.NewAppError("Handle404", "api.context.404.app_error", nil, "", http.StatusNotFound)
|
||||
ipAddress := utils.GetIPAddress(r, a.Config().ServiceSettings.TrustedProxyIPHeader)
|
||||
mlog.Debug("not found handler triggered", mlog.String("path", r.URL.Path), mlog.Int("code", 404), mlog.String("ip", ipAddress))
|
||||
@@ -75,19 +75,19 @@ func Handle404(a app.AppIface, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func IsAPICall(a app.AppIface, r *http.Request) bool {
|
||||
func IsAPICall(a *app.App, r *http.Request) bool {
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
|
||||
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "api")+"/")
|
||||
}
|
||||
|
||||
func IsWebhookCall(a app.AppIface, r *http.Request) bool {
|
||||
func IsWebhookCall(a *app.App, r *http.Request) bool {
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
|
||||
return strings.HasPrefix(r.URL.Path, path.Join(subpath, "hooks")+"/")
|
||||
}
|
||||
|
||||
func IsOAuthAPICall(a app.AppIface, r *http.Request) bool {
|
||||
func IsOAuthAPICall(a *app.App, r *http.Request) bool {
|
||||
subpath, _ := utils.GetSubpathFromConfig(a.Config())
|
||||
|
||||
if r.Method == "POST" && r.URL.Path == path.Join(subpath, "oauth", "authorize") {
|
||||
|
||||
@@ -31,7 +31,7 @@ var apiClient *model.Client4
|
||||
var URL string
|
||||
|
||||
type TestHelper struct {
|
||||
App app.AppIface
|
||||
App *app.App
|
||||
Context request.CTX
|
||||
Server *app.Server
|
||||
Web *Web
|
||||
|
||||
Ссылка в новой задаче
Block a user