Documentation
¶
Overview ¶
Package address changes where a configured app is reached (R-162, R-163, R-165).
An app's address is its spec's routing block, and changing it is a spec revision like any other edit (R-152). What this package adds is the part that is not a plain field edit: which modes the chosen routing adapter serves, what the hostname, path or port defaults to under it, and whether the result deviates from the adapter's default mode — which R-163 gates behind app.routing.override. The HTTP handler asks the authorizer; the decision of what needs asking is made here, once, for every surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct {
Routing spec.Routing
// Changed is whether it differs from the current routing. A change moves
// the app: the old address stops working, and bookmarks to it break
// (R-165), which is why the caller asks for confirmation.
Changed bool
// Override is whether the mode deviates from the adapter's default, which
// needs app.routing.override (R-163). Keeping a deviation an app already
// has is not a new one and is not asked about again.
Override bool
}
Decision is a resolved routing change.
type Option ¶
type Option struct {
AdapterRef string `json:"adapter_ref"`
Modes []spec.RoutingMode `json:"modes"`
DefaultMode spec.RoutingMode `json:"default_mode"`
BaseDomain string `json:"base_domain,omitempty"`
Domains []string `json:"domains,omitempty"`
IsDefault bool `json:"is_default"`
}
Option is a routing adapter an app can be moved to, and what it offers.
type Ports ¶
type Ports interface {
Allocate(ctx context.Context, adapterRef, appID string, from, to int) (int, error)
}
Ports allocates a host port for port-mode routing (design 03 §4.2). Idempotent: an app that holds a port on an adapter gets the same one back.
type Request ¶
type Request struct {
AdapterRef string `json:"adapter_ref,omitempty"`
Mode spec.RoutingMode `json:"mode,omitempty"`
Hostname string `json:"hostname,omitempty"`
PathPrefix string `json:"path_prefix,omitempty"`
// Domain is the domain a subdomain address is made in, when the adapter
// serves more than one: one of its Domains, such as a second Cloudflare
// zone. With no hostname the app is <slug>.<domain>; with a single label
// such as "docs" it is docs.<domain>. Empty is the adapter's base domain.
Domain string `json:"domain,omitempty"`
}
Request is the address somebody asked for. Empty fields take the adapter's default: its default mode, and the hostname, path or port that mode implies. A port is always allocated, never named.
type Service ¶
type Service struct {
Registry *api.Registry
Ports Ports
Taken Taken
// PortRangeStart and PortRangeEnd are the install's port range.
PortRangeStart, PortRangeEnd int
// BaseDomain is the install's server.base_domain, used when the routing
// adapter has no domain of its own.
BaseDomain string
}
Service resolves routing changes against the configured routing adapters.
func (*Service) Options ¶
Options lists the routing adapters an app's address can use. One that cannot say what it serves is left out rather than offered and refused.
func (*Service) Overrides ¶
func (s *Service) Overrides(ctx context.Context, current *spec.Routing, next *spec.Routing) (bool, error)
Overrides reports whether next deviates from its adapter's default mode where current did not — for a spec written whole, through POST /specs, rather than through Resolve. It also corrects next's ModeSource, which a hand-written spec may have left saying anything.
A hostname new to the app is held to the domains the adapter serves, as Resolve holds it: a spec written whole is not a way around that. One the app already has is left alone, so an adapter's domains changing later does not stop the app's next edit.