Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3fb9cff75 | ||
|
|
c7bd042239 | ||
|
|
202fa7035e | ||
|
|
602a2a1ac4 | ||
|
|
6a3abf67a2 | ||
|
|
2f88738f78 | ||
|
|
a637d56ea7 | ||
|
|
a841cd082b | ||
|
|
9b18fe7351 | ||
|
|
f3c801e4a4 | ||
|
|
ee13991d87 | ||
|
|
d4846359e4 | ||
|
|
13cf0075f6 | ||
|
|
135e551473 | ||
|
|
689f730a3e | ||
|
|
a30582fa38 | ||
|
|
5b1ce14467 | ||
|
|
264b438cdb | ||
|
|
f699aefa58 | ||
|
|
8d40e76637 | ||
|
|
e2b4becfd6 | ||
|
|
e4ef2d8645 | ||
|
|
bfc28503d5 | ||
|
|
d759f883f4 | ||
|
|
64373fdf3c | ||
|
|
1dd566593e | ||
|
|
560c1f22c4 | ||
|
|
171b85f627 | ||
|
|
734b83b2b8 | ||
|
|
bdeb2c0753 | ||
|
|
97c44fb3bd | ||
|
|
6db18c1495 | ||
|
|
cd985ff5a3 | ||
|
|
2eed857503 | ||
|
|
2b91caece0 |
No files matched your search
@@ -1,10 +1,3 @@
|
|||||||
### v5.9.4
|
|
||||||
* Добавлено логирование `requestId` в лог `throttling: rate limit has been reached for application`
|
|
||||||
### v5.9.3
|
|
||||||
* Исправлена опечатка при вызове `strings.TrimPrefix`
|
|
||||||
### v5.9.2
|
|
||||||
* При проверке `logging.skipBodyLoggingEndpointPrefixes` игнорируется `/` в начале, путь для проверки берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
|
||||||
* В логе `log request` из значения в поле `endpoint` удаляется `/` в начале, путь берётся из `pathSchema`, если `pathSchema` пустая, берётся вызываемый `endpoint`
|
|
||||||
### v5.9.1
|
### v5.9.1
|
||||||
* Добавлен `warn` лог на неизвестный endpoint
|
* Добавлен `warn` лог на неизвестный endpoint
|
||||||
### v5.9.0
|
### v5.9.0
|
||||||
|
|||||||
+1
-7
@@ -2,7 +2,6 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/metrics"
|
"github.com/txix-open/isp-kit/metrics"
|
||||||
@@ -73,11 +72,6 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
|||||||
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
|
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
|
||||||
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
|
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
|
||||||
|
|
||||||
skipBodyLoggingEndpointPrefixes := make([]string, 0, len(config.Logging.SkipBodyLoggingEndpointPrefixes))
|
|
||||||
for _, prefix := range config.Logging.SkipBodyLoggingEndpointPrefixes {
|
|
||||||
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
|
|
||||||
}
|
|
||||||
|
|
||||||
mux := mux2.NewRouter()
|
mux := mux2.NewRouter()
|
||||||
for _, location := range locations {
|
for _, location := range locations {
|
||||||
var proxyFunc middleware.Handler
|
var proxyFunc middleware.Handler
|
||||||
@@ -132,7 +126,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
|
|||||||
proxyFunc,
|
proxyFunc,
|
||||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
||||||
enableBodyLog,
|
enableBodyLog,
|
||||||
skipBodyLoggingEndpointPrefixes,
|
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
||||||
config.Logging.EnableForceUnescapingUnicode,
|
config.Logging.EnableForceUnescapingUnicode,
|
||||||
),
|
),
|
||||||
middleware.RequestId(),
|
middleware.RequestId(),
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ type Logging struct {
|
|||||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
||||||
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
||||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
||||||
SkipBodyLoggingEndpointPrefixes []string `schema:"Выключить логирование тел запросов и ответов для путей имеющих префикс из списка,'/' в начале игнорируется"`
|
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
|
||||||
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ require (
|
|||||||
github.com/redis/go-redis/v9 v9.11.0
|
github.com/redis/go-redis/v9 v9.11.0
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/tomakado/websocketproxy v0.1.0
|
github.com/tomakado/websocketproxy v0.1.0
|
||||||
github.com/txix-open/isp-kit v1.66.2
|
github.com/txix-open/isp-kit v1.65.1
|
||||||
github.com/txix-open/jsonschema v1.3.0
|
github.com/txix-open/jsonschema v1.3.0
|
||||||
golang.org/x/net v0.52.0
|
golang.org/x/net v0.52.0
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c
|
||||||
|
|||||||
@@ -123,8 +123,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/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||||
github.com/txix-open/grmq v1.10.0 h1:1bXuF+7TxtUvoh+Wn6SOCYpVACFbWDuDmz/+tKwW9Ms=
|
github.com/txix-open/grmq v1.10.0 h1:1bXuF+7TxtUvoh+Wn6SOCYpVACFbWDuDmz/+tKwW9Ms=
|
||||||
github.com/txix-open/grmq v1.10.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
github.com/txix-open/grmq v1.10.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
||||||
github.com/txix-open/isp-kit v1.66.2 h1:+AFj7g9IeWiLSShmotrdheuJuwUNUYeL49D2d7PU3zo=
|
github.com/txix-open/isp-kit v1.65.1 h1:KehXIJdPZMnewDd5XQxk87yNAtNhvJXApaLFvbUau5U=
|
||||||
github.com/txix-open/isp-kit v1.66.2/go.mod h1:F4B/+ErbNVaWzIIGasXM5DtcDKtjl6u2OESO02RyzCI=
|
github.com/txix-open/isp-kit v1.65.1/go.mod h1:F4B/+ErbNVaWzIIGasXM5DtcDKtjl6u2OESO02RyzCI=
|
||||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
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/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||||
|
|||||||
@@ -65,16 +65,10 @@ func Logger( // nolint:gocognit,funlen
|
|||||||
|
|
||||||
r := ctx.Request()
|
r := ctx.Request()
|
||||||
|
|
||||||
endpoint := ctx.EndpointMeta().Endpoint
|
|
||||||
if ctx.EndpointMeta().PathSchema != "" {
|
|
||||||
endpoint = ctx.EndpointMeta().PathSchema
|
|
||||||
}
|
|
||||||
endpoint = strings.TrimPrefix(endpoint, "/")
|
|
||||||
|
|
||||||
logBodyFromCurrenRequest := enableBodyLogging
|
logBodyFromCurrenRequest := enableBodyLogging
|
||||||
if logBodyFromCurrenRequest {
|
if logBodyFromCurrenRequest {
|
||||||
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
||||||
if strings.HasPrefix(endpoint, prefix) {
|
if strings.HasPrefix(ctx.EndpointMeta().Endpoint, prefix) {
|
||||||
logBodyFromCurrenRequest = false
|
logBodyFromCurrenRequest = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -116,7 +110,7 @@ func Logger( // nolint:gocognit,funlen
|
|||||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
||||||
log.Int("statusCode", scSrc.StatusCode()),
|
log.Int("statusCode", scSrc.StatusCode()),
|
||||||
log.String("path", originalPath),
|
log.String("path", originalPath),
|
||||||
log.String("endpoint", endpoint),
|
log.String("endpoint", ctx.EndpointMeta().Endpoint),
|
||||||
log.Int("applicationId", authData.ApplicationId),
|
log.Int("applicationId", authData.ApplicationId),
|
||||||
log.String("applicationName", authData.AppName),
|
log.String("applicationName", authData.AppName),
|
||||||
log.Int("adminId", ctx.AdminId()),
|
log.Int("adminId", ctx.AdminId()),
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
"isp-gate-service/domain"
|
"isp-gate-service/domain"
|
||||||
"isp-gate-service/httperrors"
|
"isp-gate-service/httperrors"
|
||||||
"isp-gate-service/request"
|
"isp-gate-service/request"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/requestid"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Throttler interface {
|
type Throttler interface {
|
||||||
@@ -30,12 +28,10 @@ func Throttling(throttler Throttler) Middleware {
|
|||||||
return errors.WithMessage(err, "throttling: allow rate limit")
|
return errors.WithMessage(err, "throttling: allow rate limit")
|
||||||
}
|
}
|
||||||
if !result.Allow {
|
if !result.Allow {
|
||||||
requestId := requestid.FromContext(ctx.Context())
|
|
||||||
return httperrors.New(
|
return httperrors.New(
|
||||||
http.StatusTooManyRequests,
|
http.StatusTooManyRequests,
|
||||||
fmt.Sprintf("rate limit has been reached, try after %dms", result.RetryAfter.Milliseconds()),
|
fmt.Sprintf("rate limit has been reached, try after %dms", result.RetryAfter.Milliseconds()),
|
||||||
errors.Errorf("throttling: rate limit has been reached for application '%d', requestId '%s'",
|
errors.Errorf("throttling: rate limit has been reached for application '%d'", authData.ApplicationId),
|
||||||
authData.ApplicationId, requestId),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user