PhoenixWebTransport.Router (phoenix_wtransport v0.1.0)

Copy Markdown View Source

Introspects Endpoint.__sockets__/0 (plus explicit :sockets / :socket configuration) and routes incoming WebTransport CONNECT requests across one or more Phoenix sockets sharing a single UDP listener.

Features:

  • Endpoint.__sockets__/0 introspection (websocket and optional webtransport options, skipping Phoenix.LiveReloader.Socket by default)
  • Multi-socket mounting on one listener (e.g. "/live" and "/socket")
  • Exact, parameter ("/tenant/:org/live"), and glob ("/room/*rest") path matching matching Plug.Router semantics while accepting both the mount path (/live) and the transport suffix (/live/webtransport)
  • Dev Phoenix.CodeReloader.reload/1 execution parity on upgrade

Summary

Functions

Compiles a list of routes from listener or engine options.

Matches an incoming request path against compiled routes, returning {:ok, route, path_params} or :error.

Triggers code reloading when :code_reloader is enabled in route options or on endpoint.config(:code_reloader).

Types

route()

@type route() :: %PhoenixWebTransport.Router.Route{
  endpoint: term(),
  max_frame_size: term(),
  max_in_buf_bytes: term(),
  max_lanes: term(),
  mount_path: term(),
  pattern: term(),
  socket: term(),
  socket_opts: term(),
  subpath: term(),
  subpath_segments: term()
}

Functions

compile(opts)

@spec compile(keyword()) :: [route()]

Compiles a list of routes from listener or engine options.

match(routes, raw_path)

@spec match([route()], binary()) :: {:ok, route(), map()} | :error

Matches an incoming request path against compiled routes, returning {:ok, route, path_params} or :error.

maybe_code_reload(endpoint, opts)

@spec maybe_code_reload(module(), keyword()) :: :ok

Triggers code reloading when :code_reloader is enabled in route options or on endpoint.config(:code_reloader).