Skip to content

Improve middleware integration - #5

Merged
Ret2Hell merged 6 commits into
mainfrom
dev
Mar 21, 2026
Merged

Ret2Hell merged 6 commits into
mainfrom
dev

Conversation

@Ret2Hell

@Ret2Hell Ret2Hell commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Container healthcheck moved to /livez.
    • Framework-provided request ID tracking and structured request logging enabled.
    • Security headers and idempotency support added.
  • Chores

    • Logging backend switched to a JSON-structured logger with improved output.
    • Startup now fails fast when required environment variables are missing or invalid.
    • Custom gzip request decompression and legacy readiness endpoints removed.

changed the way I'm handling env vars as default values were causing
confusion
Turns out Fiber handles gzip requests by itself so we don't need to
implement a middleware for that, in fact it was actually causing issues
as request were decompressed twice :(
added healthchech, idempotency and helmet middlewares
@coderabbitai

coderabbitai Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 71300692-2f96-462d-b64a-d3ccefb493df

📥 Commits

Reviewing files that changed from the base of the PR and between fb1888c and 27e96bb.

📒 Files selected for processing (2)
  • internal/config/config.go
  • internal/models/errors.go
💤 Files with no reviewable changes (1)
  • internal/models/errors.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/config/config.go

📝 Walkthrough

Walkthrough

Migrates logging from Go's slog to zerolog, tightens config to require environment variables, removes custom Fiber middleware and readiness handlers in favor of Fiber built-ins, updates Docker HEALTHCHECK to /livez, and adjusts module dependencies.

Changes

Cohort / File(s) Summary
Logger migration
cmd/ingest/main.go, internal/observability/logger.go, internal/producer/producer.go, internal/producer/producer_test.go, internal/server/handler.go, internal/server/server.go
Replaced *slog.Logger with *zerolog.Logger across constructors, types, and calls; converted structured logging to zerolog fluent API and updated startup/shutdown and error logs.
Configuration strictness
internal/config/config.go
Removed fallback/defaults; getEnv* helpers now require presence and non-empty env vars, log failures and call os.Exit(1) on missing/invalid values.
Health, middleware, and routing
internal/server/health.go, internal/server/middleware.go, internal/server/server.go, Dockerfile
Deleted custom readiness/health handlers and middleware (request ID, request logger, gzip decompressor); integrated Fiber built-ins (requestid.New(), fiberlogger.New(), helmet.New(), idempotency.New(), healthcheck.LivenessEndpoint); Docker HEALTHCHECK updated to /livez.
Dependency manifest
go.mod
Added direct dependency github.com/rs/zerolog v1.34.0; removed github.com/kylelemons/godebug from direct require; moved github.com/google/uuid to indirect.
Model and error cleanup
internal/models/errors.go
Removed several custom error types and their methods (ErrValidation, ErrDuplicate, ErrProduceFailed), and removed related fmt import.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A nibble of change, from slog to zerolog bright,
Env vars now stern — they must be just right,
Middleware hopped away, Fiber's built-ins arrive,
Health check renamed, the container stays live,
I thumped for the merge and danced through the night. 🥕✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

@sonarqubecloud

Copy link
Copy Markdown

@Ret2Hell
Ret2Hell merged commit 3aa717d into main Mar 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant