Skip to content

Proposal: clarify Upgrader vs Server responsibilities #259

Description

@okdaichi

Motivation

The main reason for this proposal is to reduce coupling between two different concerns:

  1. transport/connection serving lifecycle (Server, Serve, ServeQUICConn)
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions