2026-03-10 10:38:58: merge [main:aae3c282252c73901b8e48b1412f48217b1a6195];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s

This commit is contained in:
txix committed 2026-03-10 10:38:58 +03:00
1 parent 202fa7035e
commit c7bd042239
9 files changed
+48 -18

No files matched your search

+2
View File
@@ -74,3 +74,5 @@ package.json
yarn.lock
conf/config_dev.yml
.DS_Store
+1 -1
View File
@@ -1 +1 @@
5.8.1
5.9.0
+3
View File
@@ -1,3 +1,6 @@
### v5.9.0
* Теперь в зависимоси от `StatusCode` выводится соотвествующий уровень логирования: 400 -> warn, 500 -> error
* Исправлен порядок мидлварей, для корректного проброса `requestId`
### v5.8.1
* Обновлены зависимости
### v5.8.0
+4 -2
View File
@@ -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),
)
}
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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=
+10 -2
View File
@@ -50,7 +50,7 @@ func (w *writerWrapper) WriteHeader(statusCode int) {
w.ResponseWriter.WriteHeader(statusCode)
}
func Logger( // nolint:gocognit
func Logger( // nolint:gocognit,funlen
logger log.Logger,
enableRequestLogging bool,
enableBodyLogging bool,
@@ -125,7 +125,15 @@ func Logger( // nolint:gocognit
fields = append(fields, log.ByteString("response", buf.ResponseBody()))
}
logger.Debug(ctx.Context(), "log request", fields...)
switch {
case scSrc.StatusCode() >= http.StatusInternalServerError:
logger.Error(ctx.Context(), "log request", fields...)
case scSrc.StatusCode() >= http.StatusBadRequest:
logger.Warn(ctx.Context(), "log request", fields...)
default:
logger.Debug(ctx.Context(), "log request", fields...)
}
return err
})
+19 -1
View File
@@ -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)
+6 -9
View File
@@ -105,13 +105,10 @@ func (s *Routes) registerEndpoint(
PathSchema: descriptor.Path,
}
router.HandlerFunc(
httpMethod,
path,
func(_ http.ResponseWriter, r *http.Request) {
ctx := meta.ToContext(r.Context())
// хак для передачи метадаты обратно в код
*r = *r.WithContext(ctx)
},
)
handler := func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := meta.ToContext(r.Context())
// хак для передачи метадаты обратно в код
*r = *r.WithContext(ctx)
}
router.Handle(httpMethod, path, handler)
}