Добавить X-Instance-Id, задержку drain при SIGTERM и отдельный запуск миграций
This commit is contained in:
@@ -20,8 +20,9 @@ const (
|
||||
)
|
||||
|
||||
// NewEngine builds an engine whose every response, including routing
|
||||
// failures and panics, carries X-Request-Id and the contract error body.
|
||||
func NewEngine(log *slog.Logger, maxBodyBytes int64) *gin.Engine {
|
||||
// failures and panics, carries X-Instance-Id, X-Request-Id and the contract
|
||||
// error body.
|
||||
func NewEngine(log *slog.Logger, maxBodyBytes int64, instanceID string) *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
e := gin.New()
|
||||
// Redirects would answer with text/plain and without a request id.
|
||||
@@ -29,7 +30,7 @@ func NewEngine(log *slog.Logger, maxBodyBytes int64) *gin.Engine {
|
||||
e.RedirectFixedPath = false
|
||||
e.HandleMethodNotAllowed = true
|
||||
|
||||
e.Use(requestID(log), accessLog(), recovery(), bodyLimit(maxBodyBytes))
|
||||
e.Use(instance(instanceID), requestID(log), accessLog(), recovery(), bodyLimit(maxBodyBytes))
|
||||
e.NoRoute(func(c *gin.Context) { Error(c, apperr.NotFound("route not found")) })
|
||||
e.NoMethod(func(c *gin.Context) { Fail(c, http.StatusMethodNotAllowed, "invalid_request", "method not allowed") })
|
||||
return e
|
||||
|
||||
Reference in New Issue
Block a user