Merge branch 'MSP-7199' into 'dev'
Resolve MSP-7199 See merge request isp/isp-gate-service!29
This commit is contained in:
commit
40e521462d
7 files changed
+31
-7
No files matched your search
@@ -74,3 +74,5 @@ package.json
|
||||
yarn.lock
|
||||
|
||||
conf/config_dev.yml
|
||||
|
||||
.DS_Store
|
||||
@@ -1,3 +1,5 @@
|
||||
### v5.9.0
|
||||
* Исправлен порядок мидлварей, для корректного проброса `requestId`
|
||||
### v5.8.1
|
||||
* Обновлены зависимости
|
||||
### v5.8.0
|
||||
|
||||
+4
-2
@@ -107,14 +107,15 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.EnableForceUnescapingUnicode,
|
||||
),
|
||||
middleware.RequestId(),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
middleware.Authenticate(authentication),
|
||||
middleware.AdminAuthenticate(adminService),
|
||||
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
middleware.Authorize(authorization, l.logger),
|
||||
middleware.AdminAuthorize(adminService),
|
||||
middleware.Throttling(throttlingService),
|
||||
middleware.DailyLimit(dailyLimitService),
|
||||
middleware.RequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
middleware.Metrics(metricsStorage),
|
||||
)
|
||||
|
||||
@@ -128,8 +129,9 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
||||
config.Logging.EnableForceUnescapingUnicode,
|
||||
),
|
||||
middleware.RequestId(),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
middleware.RequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
middleware.ClientRequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
|
||||
middleware.Metrics(metricsStorage),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ require (
|
||||
github.com/redis/go-redis/v9 v9.11.0
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/tomakado/websocketproxy v0.1.0
|
||||
github.com/txix-open/isp-kit v1.64.8
|
||||
github.com/txix-open/isp-kit v1.64.10
|
||||
github.com/txix-open/jsonschema v1.3.0
|
||||
golang.org/x/net v0.47.0
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090
|
||||
|
||||
@@ -125,8 +125,8 @@ github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIg
|
||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
|
||||
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
||||
github.com/txix-open/isp-kit v1.64.8 h1:nck8Gw5a7Jh6AVLqR2FihurrP5bTfeLUrodYB4j4+p4=
|
||||
github.com/txix-open/isp-kit v1.64.8/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||
github.com/txix-open/isp-kit v1.64.10 h1:lAowLtShBbICZbOWQJ4ptr9LaKKRZ7CE5DBK+7LcLqM=
|
||||
github.com/txix-open/isp-kit v1.64.10/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||
|
||||
@@ -13,10 +13,28 @@ const (
|
||||
requestIdHeader = "x-request-id"
|
||||
)
|
||||
|
||||
func RequestId(forwardClientRequestId bool, forwardReqIdByApp map[int]bool) Middleware {
|
||||
func RequestId() Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
requestId := requestid.Next()
|
||||
|
||||
context := requestid.ToContext(ctx.Context(), requestId)
|
||||
context = log.ToContext(context, log.String("requestId", requestId))
|
||||
|
||||
ctx.SetContext(context)
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ClientRequestId(forwardClientRequestId bool, forwardReqIdByApp map[int]bool) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
requestId := requestid.FromContext(ctx.Context())
|
||||
if requestId == "" {
|
||||
requestId = requestid.Next()
|
||||
}
|
||||
|
||||
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
|
||||
|
||||
logFields := make([]log.Field, 0)
|
||||
|
||||
Reference in new issue
Block a user