125b8b4e

By: Michael Lynch <git@mtlynch.io>

Serve from the handler directly instead of the default ServeMux

main() wrapped the fully-assembled handler chain (CrossOriginProtection
-> optional ProxyIPHeaders -> LoggingHandler -> router) in a call to
http.Handle("/", h), which registers it on the package-global
http.DefaultServeMux, and then passed nil to http.ListenAndServe so the
server would fall back to that same default mux.

This added an indirection that bought us nothing: h is already a complete
http.Handler, so forwarding all "/" traffic through a ServeMux back into h
is redundant. It also coupled the server to global mutable state. Anything
in the process (including third-party packages) can register routes on
DefaultServeMux, which risks surprising route conflicts or accidentally
exposed endpoints, and it makes the wiring harder to follow and to test.

Drop the http.Handle("/", h) registration and pass h directly to
http.ListenAndServe. Behavior is identical, but the server now serves from
an explicit handler with no reliance on the global default mux.

Suite timing

Time to Start Worker time Duration Time to finish
Config 15s 3s 3s 19s
Eval 19s 1m03s 1m03s 1m23s
Build 1m55s 3m54s 1m35s 3m31s
Suite 15s 5m01s 3m16s 3m31s

Timeline

0s20s40s1m1m20s2m2m20s2m40s3m3m20s