Movatterモバイル変換


[0]ホーム

URL:


appurl

package
v2.23.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:7Imported by:0

Details

Repository

github.com/coder/coder

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

func CompileHostnamePattern(patternstring) (*regexp.Regexp,error)

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

func ExecuteHostnamePattern(pattern *regexp.Regexp, hostnamestring) (string,bool)

ExecuteHostnamePattern executes a pattern generated by CompileHostnamePatternand returns the wildcard match. If the pattern does not match the hostname,returns false.

funcHostnamesMatch

func HostnamesMatch(a, bstring)bool

HostnamesMatch returns true if the hostnames are equal, disregardingcapitalization, extra leading or trailing periods, and ports.

funcSubdomainAppHost

func SubdomainAppHost(apphoststring, accessURL *url.URL)string

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)ChangePortProtocoladded 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)PortInfoadded 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.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp