Skip to content

Harden middleware, problemjson, outbound and spa, with route labels and client IP - #7

Merged
andresbott merged 35 commits into
mainfrom
next-middleware
Nov 12, 2026
Merged

andresbott merged 35 commits into
mainfrom
next-middleware

Conversation

@andresbott

Copy link
Copy Markdown
Member

Summary

Several request-path packages mislabelled routes, logged or recorded requests wrongly (panics, aborts, upgrades), and mishandled edge cases (SPA paths, outbound deadlines, masked problem details). This branch fixes those and adds the missing route and client IP plumbing.

What

  • middleware: router-agnostic route labels via SetRoute/CaptureRoute (innermost reporter wins), path-only URL logging, trusted-proxy client IP; every request is logged and observed exactly once, including panics; aborted requests record 500, and 101/hijacked responses record 101.
  • problemjson: OnProblem now receives a Problem with field errors, upstream reason and error; non-error statuses are normalised; instance is the escaped path.
  • outbound: new Cfg.Timeout overall budget; waits that outlast the deadline fail at once as KindTimeout; error bodies are drained for keep-alive reuse.
  • spa: index.html is required at New; PathPrefix matches whole segments; unclean paths get 404; the request URL is never mutated.
  • build: coverage gate covers every package, make test runs with the race detector, and benchmarks are dropped from make verify.

Notes

  • Breaking: the middleware route/client IP API and the problemjson OnProblem signature changed.

…er after the response started, re-panic without PanicRecover)
@andresbott
andresbott merged commit febccb1 into main Nov 12, 2026
3 checks passed
@andresbott
andresbott deleted the next-middleware branch November 12, 2026 09:57
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