Skip to content

feat: add response controller middleware - #304

Merged
franklinkim merged 1 commit into
mainfrom
feature/responsecontroller-middleware
Aug 19, 2026
Merged

feat: add response controller middleware#304
franklinkim merged 1 commit into
mainfrom
feature/responsecontroller-middleware

Conversation

@franklinkim

Copy link
Copy Markdown
Member

Description

Add ResponseController and MaxRequestBodySize HTTP middlewares, and raise the server IdleTimeout to 620s.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactoring
  • 🏃‍➡️ Performance
  • ✅ Tests
  • 🔐 Security
  • 🔧 Build/CI

Changes

  • middleware.ResponseController(h) — runs h against the request's http.ResponseController before the handler, so read/write deadlines, full duplex and flush can be overridden per connection (e.g. clearing the write deadline for SSE). An error from h is logged and the handler still runs.
  • middleware.MaxRequestBodySize(n) — rejects a declared Content-Length over n with 413 before the handler runs, and wraps the body in http.MaxBytesReader so chunked or lying clients fail on read with *http.MaxBytesError.
  • net/http/server.goIdleTimeout 120s → 620s so the peer is always the side closing an idle connection; comment documents the managed-L7 values it clears (GCLB 600s, Azure App Gateway 240/300s, ingress-nginx 60s, ALB 60s) and the Envoy-sidecar caveat.
  • Table-driven tests for both middlewares.

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

@franklinkim
franklinkim merged commit 5a10c13 into main Aug 19, 2026
4 checks passed
@franklinkim
franklinkim deleted the feature/responsecontroller-middleware branch August 19, 2026 11:10
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