MCPcopy Index your code
hub / github.com/coder/coder / PortInfo

Method PortInfo

coderd/workspaceapps/appurl/appurl.go:98–122  ·  view source on GitHub ↗

PortInfo returns the port, protocol, and whether the AppSlugOrPort is a port or not.

()

Source from the content-addressed store, hash-verified

96
97// PortInfo returns the port, protocol, and whether the AppSlugOrPort is a port or not.
98func (a ApplicationURL) PortInfo() (uint, string, bool) {
99 var (
100 port uint64
101 protocol string
102 isPort bool
103 err error
104 )
105
106 if strings.HasSuffix(a.AppSlugOrPort, "s") {
107 trimmed := strings.TrimSuffix(a.AppSlugOrPort, "s")
108 port, err = strconv.ParseUint(trimmed, 10, 16)
109 if err == nil {
110 protocol = "https"
111 isPort = true
112 }
113 } else {
114 port, err = strconv.ParseUint(a.AppSlugOrPort, 10, 16)
115 if err == nil {
116 protocol = "http"
117 isPort = true
118 }
119 }
120
121 return uint(port), protocol, isPort
122}
123
124func (a *ApplicationURL) ChangePortProtocol(target string) ApplicationURL {
125 newAppURL := *a

Callers 3

ChangePortProtocolMethod · 0.95
ReverseProxyMethod · 0.80
proxyWorkspaceAppMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected