• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tecnickcom / gogen / 28739301420

05 Jul 2026 11:29AM UTC coverage: 99.959% (-0.008%) from 99.967%
28739301420

push

github

nicolaasuni
feat(httpserver): startup validation, request limits, HTTP/2, and lifecycle observability

Major hardening and observability upgrade for pkg/httpserver, with a matching response-writer addition in pkg/httputil.

API:
- New options: WithServerMaxHeaderBytes and WithMaxRequestBodyBytes (enforced via http.MaxBytesHandler, so handlers can detect *http.MaxBytesError and answer 413) for public-listener hardening; WithTLSConfig for full TLS control; WithoutNotFoundLogger and WithoutMethodNotAllowedLogger to silence the 404/405 request loggers.
- New lifecycle API: HTTPServer.Addr exposes the bound listener address (binding to the ephemeral port ":0" is now valid) and HTTPServer.ServeError reports abnormal Serve failures on a buffered channel.
- Route.Timeout gains the DisableTimeout sentinel: a negative value exempts a route from the global request timeout (applied by default to the streaming /pprof profile route); a positive value still overrides the global one.
- Exported sentinel errors (ErrNilBinder, ErrNilRouteHandler, ErrNilRouteMiddleware, ErrInvalidRouteMethod, ErrInvalidRoutePath, ErrDuplicateRoute, ErrRouteRegistration, ErrUnknownDefaultRoute, ErrInvalidTLSConfig) so misconfiguration is reported by New as wrapped errors instead of panics.

Startup validation:
- New rejects nil binders, nil route handlers or middleware entries, empty or non-'/' paths, non-uppercase methods (httprouter matches case-sensitively), duplicate method+path pairs, and unknown default-route identifiers; router registration panics (e.g. wildcard conflicts) are converted to errors.
- TLS configurations without certificate material are rejected before the listener binds; repeated default-route identifiers are de-duplicated.

Transport and lifecycle:
- TLS listeners advertise HTTP/2 and HTTP/1.1 via ALPN, the accepted protocol set is pinned explicitly, and the TLS path now honors the caller's context (net.ListenConfig + tls.NewListener).
- Request contexts inherit values from th... (continued)

292 of 293 new or added lines in 6 files covered. (99.66%)

12334 of 12339 relevant lines covered (99.96%)

101592.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.62
/pkg/httpserver/httpserver.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc