waf.Server and rproxy.Server hold Go's server as a private field #437

Open
opened 2026-11-19 17:13:07 +01:00 by clawbot · 1 comment
Collaborator

Start once the issue that removes the parts from waf.Server is closed: #436. Both rewrite that type and the test helpers that use it.

From the architecture review, "The HTTP surface", under "Both Server types embed *http.Server": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next, where discriminator is now waf. Line numbers are that commit's.

What is there

  • waf.Server (internal/waf/proxy.go:121) and rproxy.Server (internal/rproxy/rproxy.go:70) embed *http.Server. Every field and method of Go's server is then part of their own API: Handler, Addr, ListenAndServe, RegisterOnShutdown and the rest.
  • internal/sww takes the embedded server out with a provider for each daemon, func(server *waf.Server) *http.Server { return server.Server }, and its serve hook (internal/sww/lifecycle.go:102) calls three methods on it: Serve, Shutdown, Close.
  • The tests use more: server.Addr, server.Serve, server.Close, server.Handler.ServeHTTP, and s.Handler.(*handler) in internal/waf/export_test.go.

Why it matters

  • GO_HTTP_SERVER_CONVENTIONS.md holds Go's server as a private field, httpServer *http.Server, and makes Server the handler.
  • The review rates the gain in reading as small: nothing misuses the embedded server today.

What changes

  • Each Server holds Go's server as a private field.
  • Each Server gets ServeHTTP, and the three methods internal/sww needs to start and stop it: Serve, Shutdown, Close.
  • sww's serve hook takes those three methods as one small interface declared beside it in internal/sww, in place of *http.Server. The two providers that take the embedded server out go.
  • The tests call ServeHTTP on the Server, and the test helpers that set server.Addr keep the listener's address themselves.

The review wrote this before the fx wiring, and counted one method per Server. The shared serve hook needs the three.

What stays

  • Every setting of Go's server that New makes today: the timeouts, the error log, the limit on the size of the headers.
  • How each daemon starts and stops, and rproxy.Server.WaitForReports.

Done when

  • neither Server embeds *http.Server, and neither exports it;
  • internal/sww reaches Go's server only through the three methods;
  • behaviour is unchanged: every existing test passes with no assertion changed;
  • make check passes;
  • the PR body lists the new interface's name and each new method's.

If this is more than one PR can carry, say so on this issue instead of starting.

Model: fable-5-2

**Start once the issue that removes the parts from `waf.Server` is closed: https://git.eeqj.de/sneak/smallwebwaf/issues/436.** Both rewrite that type and the test helpers that use it. From the architecture review, "The HTTP surface", under "Both `Server` types embed `*http.Server`": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173836. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`, where `discriminator` is now `waf`. Line numbers are that commit's. ### What is there - `waf.Server` (`internal/waf/proxy.go:121`) and `rproxy.Server` (`internal/rproxy/rproxy.go:70`) embed `*http.Server`. Every field and method of Go's server is then part of their own API: `Handler`, `Addr`, `ListenAndServe`, `RegisterOnShutdown` and the rest. - `internal/sww` takes the embedded server out with a provider for each daemon, `func(server *waf.Server) *http.Server { return server.Server }`, and its `serve` hook (`internal/sww/lifecycle.go:102`) calls three methods on it: `Serve`, `Shutdown`, `Close`. - The tests use more: `server.Addr`, `server.Serve`, `server.Close`, `server.Handler.ServeHTTP`, and `s.Handler.(*handler)` in `internal/waf/export_test.go`. ### Why it matters - `GO_HTTP_SERVER_CONVENTIONS.md` holds Go's server as a private field, `httpServer *http.Server`, and makes `Server` the handler. - The review rates the gain in reading as small: nothing misuses the embedded server today. ### What changes - Each `Server` holds Go's server as a private field. - Each `Server` gets `ServeHTTP`, and the three methods `internal/sww` needs to start and stop it: `Serve`, `Shutdown`, `Close`. - `sww`'s `serve` hook takes those three methods as one small interface declared beside it in `internal/sww`, in place of `*http.Server`. The two providers that take the embedded server out go. - The tests call `ServeHTTP` on the `Server`, and the test helpers that set `server.Addr` keep the listener's address themselves. The review wrote this before the fx wiring, and counted one method per `Server`. The shared `serve` hook needs the three. ### What stays - Every setting of Go's server that `New` makes today: the timeouts, the error log, the limit on the size of the headers. - How each daemon starts and stops, and `rproxy.Server.WaitForReports`. ### Done when - neither `Server` embeds `*http.Server`, and neither exports it; - `internal/sww` reaches Go's server only through the three methods; - behaviour is unchanged: every existing test passes with no assertion changed; - `make check` passes; - the PR body lists the new interface's name and each new method's. If this is more than one PR can carry, say so on this issue instead of starting. Model: fable-5-2
clawbot self-assigned this 2026-11-19 17:13:07 +01:00
clawbot added the needs-decision label 2026-11-19 17:23:47 +01:00
Author
Collaborator

Not started: this issue waits for #436 to close, which is still open with no PR.

Model: opus-5-5

Not started: this issue waits for https://git.eeqj.de/sneak/smallwebwaf/issues/436 to close, which is still open with no PR. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#437