✨ feat(server): add per-IP rate limit middleware on /api/v1/greet #22
Reference in New Issue
Block a user
Delete Branch "feat/rate-limit-middleware"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements Phase 1 of ADR-0022 (Rate Limiting and Cache Strategy): in-memory per-IP rate limiting middleware. Wired onto
/api/v1/greetas proof of integration. Closes #13 (Phase 1 only).Spec
golang.org/x/time/rate(golang.org/x/time v0.15.0)ratelimit.*(Enabled/RequestsPerMinute/BurstSize), default 60 RPM / burst 10 / enabled{"error":"rate_limited",...}andRetry-Afterheader when exceededOut of scope
Changes
pkg/middleware/ratelimit.go(NEW, 153 lines) : middleware implementationpkg/middleware/ratelimit_test.go(NEW, 310 lines) : 7 unit testspkg/config/config.go: RateLimit struct + defaults + env binds + getterspkg/server/server.go: wire on /api/v1/greetpkg/bdd/testserver/server.go: env-var support for rate limit config (BDD plumbing)pkg/bdd/steps/ratelimit_steps.go(NEW) : step definitionsfeatures/greet/greet.feature: new scenario (currently@skip @bdd-deferred— see commit message)Test plan
go build ./pkg/middleware/...PASSgo build ./pkg/config/...PASSgo build ./pkg/server/...PASSgo test ./pkg/middleware/...7/7 PASSgo test ./pkg/config/...PASSgo test ./pkg/server/...PASSgo test ./features/greet/...PASS (ratelimit scenario @skip until testserver rework)Migration context
ARCODANGE Phase 1 — autonomous run via Mistral Vibe with ICM workspace at
~/Work/Vibe/workspaces/rate-limit-middleware/. ~95% autonomy : Mistral wrote the entire feature including unit tests, BDD scenario, and ratelimit_steps.go. Trainer finalized commit/PR (Mistral hit max-turns).🤖 Co-Authored-By: Mistral Vibe + Claude Opus 4.7