Conversation
docs: Add build status badges for all services in README.md for impro…
WalkthroughThe gateway routing logic is refactored to use per-service path-prefix routing with conditional authentication middleware and header injection. Proxy request logging, custom error handling, and health endpoint resilience are added. All services in the configuration have unified strip_prefix values. Changes
Sequence DiagramsequenceDiagram
autonumber
participant Client
participant Gateway
participant AuthMiddleware
participant ReverseProxy
participant Service
Client->>Gateway: HTTP Request to /api/v1/users/123
Gateway->>Gateway: Match pathPrefix "/api/v1/users"
Gateway->>Gateway: Check auth_required for service
alt Auth Required
Gateway->>AuthMiddleware: Apply auth middleware
AuthMiddleware->>AuthMiddleware: Validate credentials
end
Gateway->>Gateway: Strip prefix "/api/v1"<br/>(path becomes "/users/123")
Gateway->>ReverseProxy: Forward request
ReverseProxy->>Gateway: Log: method, path, host, headers
ReverseProxy->>Service: Proxy to service
alt Success
Service-->>ReverseProxy: 200 OK
ReverseProxy-->>Client: Response
else Proxy Error
ReverseProxy->>Gateway: CustomErrorHandler triggered
Gateway->>Gateway: Log target, error, path, method
Gateway-->>Client: 502 Bad Gateway
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| logger.Info("proxying request", | ||
| "method", req.Method, | ||
| "original_path", req.URL.Path, | ||
| "target_host", target.Host, | ||
| "headers", req.Header, | ||
| ) |
There was a problem hiding this comment.
Remove sensitive header logging
Dumping the entire req.Header leaks bearer tokens and other sensitive credentials to the gateway logs, creating a serious security and compliance exposure. Please drop the header dump (or at least explicitly whitelist non-sensitive headers) before we ship.
- logger.Info("proxying request",
- "method", req.Method,
- "original_path", req.URL.Path,
- "target_host", target.Host,
- "headers", req.Header,
- )
+ logger.Info("proxying request",
+ "method", req.Method,
+ "original_path", req.URL.Path,
+ "target_host", target.Host,
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logger.Info("proxying request", | |
| "method", req.Method, | |
| "original_path", req.URL.Path, | |
| "target_host", target.Host, | |
| "headers", req.Header, | |
| ) | |
| logger.Info("proxying request", | |
| "method", req.Method, | |
| "original_path", req.URL.Path, | |
| "target_host", target.Host, | |
| ) |
🤖 Prompt for AI Agents
In cmd/gateway/main.go around lines 106 to 111, the logger currently dumps the
entire req.Header which can leak sensitive values (bearer tokens, cookies,
etc.); remove the req.Header dump and instead log only a safe, explicit
whitelist of headers (for example: Content-Type, Accept, User-Agent,
X-Request-ID) or build a filtered copy that redacts/omits any Authorization,
Cookie, Set-Cookie, and other sensitive headers before logging; implement the
whitelist/filtering when calling logger.Info so no raw headers are emitted.
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements