Motivation
The main reason for this proposal is to reduce coupling between two different concerns:
- transport/connection serving lifecycle (
Server, Serve, ServeQUICConn)
- request handshake/session-upgrade logic (
Upgrade)
In practice, keeping both on Server means callers often need to retain a Server instance just to perform upgrades in handlers, even when they don’t need the full serving lifecycle there.
Proposed direction
- Keep upgrade/session-establishment logic centered in
Upgrader.
- Keep
Server focused on serving/lifecycle responsibilities.
- Keep
Server.Upgrade as a compatibility shim so migration can be gradual.
This makes the boundary explicit and simplifies handler-side usage.
Practical benefit
This also enables more flexible route-level configuration (for example, per-path ApplicationProtocols by using different Upgrader instances), which is harder to express cleanly when Upgrade only lives on Server.
API design consistency
This direction is also similar to the API shape in gorilla/websocket, where upgrade logic is exposed via a dedicated Upgrader type.
Reference: https://github.com/gorilla/websocket/blob/main/server.go
Motivation
The main reason for this proposal is to reduce coupling between two different concerns:
Server,Serve,ServeQUICConn)Upgrade)In practice, keeping both on
Servermeans callers often need to retain aServerinstance just to perform upgrades in handlers, even when they don’t need the full serving lifecycle there.Proposed direction
Upgrader.Serverfocused on serving/lifecycle responsibilities.Server.Upgradeas a compatibility shim so migration can be gradual.This makes the boundary explicit and simplifies handler-side usage.
Practical benefit
This also enables more flexible route-level configuration (for example, per-path
ApplicationProtocolsby using differentUpgraderinstances), which is harder to express cleanly whenUpgradeonly lives onServer.API design consistency
This direction is also similar to the API shape in
gorilla/websocket, where upgrade logic is exposed via a dedicatedUpgradertype.Reference: https://github.com/gorilla/websocket/blob/main/server.go