appurl
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package appurl handles all parsing/validation/etc around application URLs.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcCompileHostnamePattern¶
CompileHostnamePattern compiles a hostname pattern into a regular expression.A hostname pattern is a string that may contain a single wildcard characterat the beginning. The wildcard character matches any number of hostname-safecharacters excluding periods. The pattern is case-insensitive.
The supplied pattern:
- must not start or end with a period
- must contain exactly one asterisk at the beginning
- must not contain any other wildcard characters
- must not contain any other characters that are not hostname-safe (includingwhitespace)
- must contain at least two hostname labels/segments (i.e. "foo" or "*" arenot valid patterns, but "foo.bar" and "*.bar" are).
The returned regular expression will match an entire hostname with optionaltrailing periods and whitespace. The first submatch will be the wildcardmatch.
funcExecuteHostnamePattern¶
ExecuteHostnamePattern executes a pattern generated by CompileHostnamePatternand returns the wildcard match. If the pattern does not match the hostname,returns false.
funcHostnamesMatch¶
HostnamesMatch returns true if the hostnames are equal, disregardingcapitalization, extra leading or trailing periods, and ports.
funcSubdomainAppHost¶
SubdomainAppHost returns the URL of the apphost for subdomain based apps.It will omit the scheme.
Arguments:apphost: Expected to contain a wildcard, example: "*.coder.com"accessURL: The access url for the deployment.
Returns:'apphost:port'
For backwards compatibility and for "accessurl=localhost:0" purposes, we needto use the port from the accessurl if the apphost doesn't have a port.If the user specifies a port in the apphost, we will use that port instead.
Types¶
typeApplicationURL¶
type ApplicationURL struct {PrefixstringAppSlugOrPortstringAgentNamestringWorkspaceNamestringUsernamestring}
ApplicationURL is a parsed application URL hostname.
funcParseSubdomainAppURL¶
func ParseSubdomainAppURL(subdomainstring) (ApplicationURL,error)
ParseSubdomainAppURL parses an ApplicationURL from the given subdomain. Ifthe subdomain is not a valid application URL hostname, returns a non-nilerror. If the hostname is not a subdomain of the given base hostname, returnsa non-nil error.
Subdomains should be in the form:
({PREFIX}---)?{PORT{s?}/APP_SLUG}--{AGENT_NAME}--{WORKSPACE_NAME}--{USERNAME}e.g. https://8080--main--dev--dean.hi.c8s.io https://8080s--main--dev--dean.hi.c8s.io https://app--main--dev--dean.hi.c8s.io https://prefix---8080--main--dev--dean.hi.c8s.io https://prefix---app--main--dev--dean.hi.c8s.io
The optional prefix is permitted to allow customers to put additional URL atthe beginning of their application URL (i.e. if they want to simulatedifferent subdomains on the same app/port).
Prefix requires three hyphens at the end to separate it from the rest of theURL so we can add/remove segments in the future from the parsing logic.
TODO(dean): make the agent name optional when using the app slug. This willreduce the character count for app URLs.
func (*ApplicationURL)ChangePortProtocol¶added inv2.11.0
func (a *ApplicationURL) ChangePortProtocol(targetstring)ApplicationURL
func (ApplicationURL)Path¶
func (aApplicationURL) Path()string
Path is a helper function to get the url path of the app if it is not servedon a subdomain. In practice this is not really used because we use the chi`{variable}` syntax to extract these parts. For testing purposes and forcompleteness of this package, we include it.
func (ApplicationURL)PortInfo¶added inv2.11.0
func (aApplicationURL) PortInfo() (uint,string,bool)
PortInfo returns the port, protocol, and whether the AppSlugOrPort is a port or not.
func (ApplicationURL)String¶
func (aApplicationURL) String()string
String returns the application URL hostname without scheme. You will likelywant to append a period and the base hostname.