Skip to content

feat(middleware): implement FixedWindow rate limiter and enhance time…#23

Merged
KARTIKrocks merged 1 commit into
mainfrom
feat/middleware-fixedwindow-timeout-flush
Apr 4, 2026
Merged

feat(middleware): implement FixedWindow rate limiter and enhance time…#23
KARTIKrocks merged 1 commit into
mainfrom
feat/middleware-fixedwindow-timeout-flush

Conversation

@KARTIKrocks
Copy link
Copy Markdown
Owner

…outWriter functionality

Summary

Changed

  • middleware — Renamed TokenBucketFixedWindow and NewTokenBucketNewFixedWindow to accurately reflect the fixed-window counter algorithm; default limiter in RateLimit() updated accordingly

Added

  • middlewaretimeoutWriter.Unwrap() returns the underlying http.ResponseWriter, enabling http.Flusher/http.Hijacker detection via http.ResponseController
  • middlewaretimeoutWriter.Flush() implements http.Flusher with timeout-aware guarding, allowing SSE and chunked responses through the timeout middleware
  • middleware — Doc comment on Timeout clarifying goroutine leak behavior when a handler does not respect context cancellation

Removed

  • middlewareTokenBucket and NewTokenBucket (replaced by FixedWindow and NewFixedWindow)

Checklist

  • fmt, vet, lint, test, build passes (make all)
  • New code has tests where appropriate
  • Breaking changes are documented

@KARTIKrocks KARTIKrocks merged commit 38d1861 into main Apr 4, 2026
10 checks passed
@KARTIKrocks KARTIKrocks deleted the feat/middleware-fixedwindow-timeout-flush branch April 4, 2026 15:32
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