Documentation
¶
Overview ¶
Package template renders the templated fields used by the proxy against per-request values.
Templates are ordinary text/template source. They are bound to the context they render against:
- ParseRouting yields a template over a RoutingContext (local namespace and metadata), used while routing rules choose an upstream. The remote namespace is not available here because translation is defined per upstream.
- ParseUpstream yields a template over an UpstreamContext (local and remote namespace, and metadata), used to render the chosen upstream's hostPort and serverName.
A reference to a field absent from the bound context (such as RemoteNamespace in a routing template) fails at parse time. A reference to an absent metadata key renders as the empty string.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RoutingContext ¶
RoutingContext is available when evaluating routing rules, before an upstream has been selected. It deliberately omits the remote namespace: namespace translation is defined per upstream, so the remote name is not known until routing has chosen one.
type Template ¶
type Template[T any] struct { // contains filtered or unexported fields }
Template is a compiled template bound to the context type T it renders against. Construct one with ParseRouting or ParseUpstream.
func Must ¶
Must returns t or panics if err is non-nil. It wraps a Parse call for package-level variables and tests where an invalid template is a programming error.
func ParseRouting ¶
func ParseRouting(s string) (*Template[RoutingContext], error)
ParseRouting compiles s into a Template rendered against a RoutingContext. A reference to a field absent from that context (such as RemoteNamespace) fails here rather than at request time.
func ParseUpstream ¶
func ParseUpstream(s string) (*Template[UpstreamContext], error)
ParseUpstream compiles s into a Template rendered against an UpstreamContext.