MCPcopy Index your code
hub / github.com/ddev/ddev / GetAllURLs

Method GetAllURLs

pkg/ddevapp/ddevapp.go:3479–3516  ·  view source on GitHub ↗

GetAllURLs returns an array of all the URLs for the project

()

Source from the content-addressed store, hash-verified

3477
3478// GetAllURLs returns an array of all the URLs for the project
3479func (app *DdevApp) GetAllURLs() (httpURLs []string, httpsURLs []string, allURLs []string) {
3480 if nodeps.IsCodespaces() {
3481 codespaceName := os.Getenv("CODESPACE_NAME")
3482 previewDomain := os.Getenv("GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN")
3483 if codespaceName != "" && previewDomain != "" {
3484 url := fmt.Sprintf("https://%s-%s.%s", codespaceName, app.HostWebserverPort, previewDomain)
3485 httpsURLs = append(httpsURLs, netutil.NormalizeURL(url))
3486 }
3487 }
3488
3489 // Get configured URLs
3490 for _, name := range app.GetHostnames() {
3491 httpPort := app.GetPrimaryRouterHTTPPort()
3492 httpsPort := app.GetPrimaryRouterHTTPSPort()
3493
3494 // It's possible for no https default to be configured
3495 if !app.CanUseHTTPOnly() && httpsPort != "" {
3496 httpsURL := netutil.NormalizeURL("https://" + name + ":" + httpsPort)
3497 httpsURLs = append(httpsURLs, httpsURL)
3498 }
3499 if httpPort != "" {
3500 httpURL := netutil.NormalizeURL("http://" + name + ":" + httpPort)
3501 httpURLs = append(httpURLs, httpURL)
3502 }
3503 }
3504
3505 if !IsRouterDisabled(app) && !app.CanUseHTTPOnly() {
3506 if directHTTPSURL := app.GetWebContainerDirectHTTPSURL(); directHTTPSURL != "" {
3507 httpsURLs = append(httpsURLs, directHTTPSURL)
3508 }
3509 }
3510 if directHTTPURL := app.GetWebContainerDirectHTTPURL(); directHTTPURL != "" {
3511 httpURLs = append(httpURLs, app.GetWebContainerDirectHTTPURL())
3512 }
3513
3514 allURLs = append(httpsURLs, httpURLs...)
3515 return httpURLs, httpsURLs, allURLs
3516}
3517
3518// GetPrimaryURL returns the primary URL that can be used, https or http
3519func (app *DdevApp) GetPrimaryURL() string {

Callers 9

DescribeMethod · 0.95
GetPrimaryURLMethod · 0.95
TestGetAllURLsFunction · 0.80
TestTraefikSimpleFunction · 0.80
TestTraefikVirtualHostFunction · 0.80
renderAppDescribeFunction · 0.80

Calls 9

GetHostnamesMethod · 0.95
CanUseHTTPOnlyMethod · 0.95
IsCodespacesFunction · 0.92
NormalizeURLFunction · 0.92
IsRouterDisabledFunction · 0.85

Tested by 6

TestGetAllURLsFunction · 0.64
TestTraefikSimpleFunction · 0.64
TestTraefikVirtualHostFunction · 0.64