Hold Go's server privately in waf.Server and rproxy.Server (closes #437) #481

Merged
clawbot merged 1 commits from issue-437-private-http-server into next 2026-11-20 01:58:26 +01:00
Collaborator

Closes #437

waf.Server and rproxy.Server no longer embed *http.Server. Each holds Go's server in a private httpServer field and is that server's handler. Every setting New made stays.

New interface, in internal/sww/lifecycle.go beside serve:

  • daemonServer: Serve(net.Listener) error, Shutdown(context.Context) error, Close() error.

New methods, on both waf.Server and rproxy.Server:

  • Serve, Shutdown, Close: each calls Go's server's method of that name.
  • ServeHTTP: passes the request to the package's handler.

sww provides each Server as a daemonServer with fx.Annotate and fx.As; the two providers that took out the embedded server are gone. rproxy also keeps fx.Self(), since run calls WaitForReports on *rproxy.Server.

Tests:

  • Calls to server.Handler.ServeHTTP are now server.ServeHTTP.
  • The waf test helper wafAndParts has its own Addr field, which serve sets to the listener's address.
  • Judgement call: TestServerHasTheFixedLimits, TestServerHasTheTimeLimitsSPECGives and TestQuestionWhoseBodyStopsArrivingGetsNoAnswer reach Go's server through HTTPServer(). That method is in each package's export_test.go, so only tests see it. The checked values are unchanged; in the waf limits test the variable holding the server is renamed.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/437 `waf.Server` and `rproxy.Server` no longer embed `*http.Server`. Each holds Go's server in a private `httpServer` field and is that server's handler. Every setting `New` made stays. New interface, in `internal/sww/lifecycle.go` beside `serve`: - `daemonServer`: `Serve(net.Listener) error`, `Shutdown(context.Context) error`, `Close() error`. New methods, on both `waf.Server` and `rproxy.Server`: - `Serve`, `Shutdown`, `Close`: each calls Go's server's method of that name. - `ServeHTTP`: passes the request to the package's handler. `sww` provides each `Server` as a `daemonServer` with `fx.Annotate` and `fx.As`; the two providers that took out the embedded server are gone. rproxy also keeps `fx.Self()`, since `run` calls `WaitForReports` on `*rproxy.Server`. Tests: - Calls to `server.Handler.ServeHTTP` are now `server.ServeHTTP`. - The waf test helper `wafAndParts` has its own `Addr` field, which `serve` sets to the listener's address. - Judgement call: `TestServerHasTheFixedLimits`, `TestServerHasTheTimeLimitsSPECGives` and `TestQuestionWhoseBodyStopsArrivingGetsNoAnswer` reach Go's server through `HTTPServer()`. That method is in each package's `export_test.go`, so only tests see it. The checked values are unchanged; in the waf limits test the variable holding the server is renamed. Model: opus-5-5
clawbot self-assigned this 2026-11-20 01:33:27 +01:00
clawbot added 1 commit 2026-11-20 01:33:27 +01:00
Neither Server embeds *http.Server any more. Each holds it as a private
field, is its handler, and has Serve, Shutdown, Close and ServeHTTP.
sww's serve hook takes the new daemonServer interface of those first
three, and fx provides each Server as it.

Model: opus-5-5
clawbot added the needs-review label 2026-11-20 01:33:31 +01:00
Author
Collaborator

Verdict: PASS
Head: ad7ea4608b

Both Server types now hold Go's server privately and act as its handler, and internal/sww reaches it only through daemonServer, which meets the issue's definition of done.

Judgement call: the test-only HTTPServer() in each export_test.go does not count as exporting Go's server, since only test builds compile it.

Model: opus-5-5

Verdict: PASS Head: ad7ea4608b68e0db9d554ee1edb919ab9ec27a0f Both `Server` types now hold Go's server privately and act as its handler, and `internal/sww` reaches it only through `daemonServer`, which meets the issue's definition of done. Judgement call: the test-only `HTTPServer()` in each `export_test.go` does not count as exporting Go's server, since only test builds compile it. Model: opus-5-5
clawbot merged commit 1b9ca94774 into next 2026-11-20 01:58:26 +01:00
Sign in to join this conversation.