Skip to content

feat: ensure all handlers explicitly set HTTP status codes#193

Merged
q-uint merged 2 commits intomasterfrom
feat/explicit-status-codes
Mar 24, 2026
Merged

feat: ensure all handlers explicitly set HTTP status codes#193
q-uint merged 2 commits intomasterfrom
feat/explicit-status-codes

Conversation

@q-uint
Copy link
Collaborator

@q-uint q-uint commented Mar 24, 2026

Wrap ResponseWriter in ServeHTTP with a statusResponseWriter that guarantees WriteHeader is always called explicitly. This allows observability middleware to reliably capture status codes, which was not possible when handlers relied on net/http's implicit 200 on first Write call.

The wrapper also guards against duplicate WriteHeader calls by ignoring subsequent invocations after the first.

Closes #183

q-uint and others added 2 commits March 24, 2026 16:37
Wrap ResponseWriter in ServeHTTP with a statusResponseWriter that
guarantees WriteHeader is always called explicitly. This allows
observability middleware to reliably capture status codes, which
was not possible when handlers relied on net/http's implicit 200
on first Write call.

The wrapper also guards against duplicate WriteHeader calls by
ignoring subsequent invocations after the first.

Closes #183

Co-Authored-By: iwarapter <iwarapter@users.noreply.github.com>
@q-uint q-uint merged commit 973ea61 into master Mar 24, 2026
8 checks passed
@q-uint q-uint deleted the feat/explicit-status-codes branch March 24, 2026 15:52
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