Add webhook logging, pagination, middleware, migrations, and prod hardening

- Webhook event logging repo and subscription webhook idempotency
- Pagination helper (echohelpers) with cursor/offset support
- Request ID and structured logging middleware
- Push client improvements (FCM HTTP v1, better error handling)
- Task model version column, business constraint migrations, targeted indexes
- Expanded categorization chain tests
- Email service and config hardening
- CI workflow updates, .gitignore additions, .env.example updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
treyt
2026-02-24 21:32:09 -06:00
parent 806bd07f80
commit e26116e2cf
50 changed files with 1681 additions and 97 deletions

View File

@@ -0,0 +1,43 @@
package middleware
import (
"github.com/google/uuid"
"github.com/labstack/echo/v4"
)
const (
// HeaderXRequestID is the header key for request correlation IDs
HeaderXRequestID = "X-Request-ID"
// ContextKeyRequestID is the echo context key for the request ID
ContextKeyRequestID = "request_id"
)
// RequestIDMiddleware generates a UUID per request, sets it as X-Request-ID header,
// and stores it in the echo context for downstream use.
func RequestIDMiddleware() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// Use existing request ID from header if present, otherwise generate one
reqID := c.Request().Header.Get(HeaderXRequestID)
if reqID == "" {
reqID = uuid.New().String()
}
// Store in context
c.Set(ContextKeyRequestID, reqID)
// Set response header
c.Response().Header().Set(HeaderXRequestID, reqID)
return next(c)
}
}
}
// GetRequestID extracts the request ID from the echo context
func GetRequestID(c echo.Context) string {
if id, ok := c.Get(ContextKeyRequestID).(string); ok {
return id
}
return ""
}