Documentation
¶
Overview ¶
Package uri parses and validates "moqt" URIs and their fragment identifiers as defined by draft-ietf-moq-transport-19 §3.1.1 and §3.1.2.
moqt-URI = "moqt" "://" authority path-abempty [ "?" query ]
A parsed URI exposes everything the connection-setup paths need: URI.HostPort for dialing (applying the §3.1.1 default port of 443), URI.Authority and URI.PathAndQuery for the AUTHORITY / PATH Setup Options carried on a native-QUIC connection (§3.1.4 / §10.3.1), and URI.HTTPSURL for the https URL a WebTransport client connects to (§3.1.3). Fragments are parsed and validated but, per §3.1.2, are processed locally by the client and never transmitted to the server.
The package depends only on the standard library so it can be used from any layer of the stack without pulling in the session machinery.
Index ¶
Constants ¶
const DefaultPort = "443"
DefaultPort is used when the authority omits an explicit port (§3.1.1: "If the port is omitted in the URI, a default port of 443 is used").
const Scheme = "moqt"
Scheme is the URI scheme defined for MOQT servers (§3.1.1).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fragment ¶
type Fragment struct {
// Type is the registered fragment type identifier: a non-empty string of
// ASCII lowercase letters, digits, and hyphens (a-z, 0-9, -).
Type string
// Value is the type-specific value following the first colon. Its
// semantics are defined by the specification that registers Type.
Value string
}
Fragment is a parsed moqt URI fragment identifier (§3.1.2):
moqt://example.com/app#<type>:<value>
type URI ¶
type URI struct {
// Authority is the host[:port] exactly as supplied (no default port
// filled in). The host subcomponent is guaranteed non-empty.
Authority string
// Host is the host subcomponent of the authority, without any port.
Host string
// Port is the explicit port from the authority, or [DefaultPort] when the
// authority omitted one.
Port string
// Path is the path-abempty component: either empty or beginning with "/".
Path string
// RawQuery is the query component without its leading "?", empty when the
// URI carried no query.
RawQuery string
// Fragment is the parsed fragment identifier, or nil when the URI carried
// none. Per §3.1.2 the fragment is processed locally and never sent to
// the server.
Fragment *Fragment
}
URI is a parsed, validated "moqt" URI (§3.1.1).
func Parse ¶
Parse parses and validates a "moqt" URI per §3.1.1 / §3.1.2. It returns an error when the scheme is not "moqt", the URI is not hierarchical, the authority has an empty host, or a present fragment does not match the "type:value" grammar.
func (*URI) HTTPSURL ¶
HTTPSURL converts the moqt URI to the https URL a WebTransport client connects to (§3.1.3): the scheme is replaced with https and the authority, path, and query are preserved. The fragment is omitted because it is processed locally and never sent to the server (§3.1.2).
func (*URI) HostPort ¶
HostPort returns the "host:port" string for dialing, applying the §3.1.1 default port of 443 when the URI omitted one.
func (*URI) PathAndQuery ¶
PathAndQuery returns the path-abempty with the query appended, the value to carry in the PATH Setup Option (§3.1.4 / §10.3.1.2). It is empty when the URI has neither a path nor a query.