MCPcopy
hub / github.com/caddyserver/caddy / String

Method String

caddyconfig/httpcaddyfile/addresses.go:425–452  ·  view source on GitHub ↗

String returns a human-readable form of a. It will be a cleaned-up and filled-out URL string.

()

Source from the content-addressed store, hash-verified

423// String returns a human-readable form of a. It will
424// be a cleaned-up and filled-out URL string.
425func (a Address) String() string {
426 if a.Host == "" && a.Port == "" {
427 return ""
428 }
429 scheme := a.Scheme
430 if scheme == "" {
431 if a.Port == strconv.Itoa(certmagic.HTTPSPort) {
432 scheme = "https"
433 } else {
434 scheme = "http"
435 }
436 }
437 s := scheme
438 if s != "" {
439 s += "://"
440 }
441 if a.Port != "" &&
442 ((scheme == "https" && a.Port != strconv.Itoa(caddyhttp.DefaultHTTPSPort)) ||
443 (scheme == "http" && a.Port != strconv.Itoa(caddyhttp.DefaultHTTPPort))) {
444 s += net.JoinHostPort(a.Host, a.Port)
445 } else {
446 s += a.Host
447 }
448 if a.Path != "" {
449 s += a.Path
450 }
451 return s
452}
453
454// Normalize returns a normalized version of a.
455func (a Address) Normalize() Address {

Callers 9

parseVariadicFunction · 0.45
FormatFunction · 0.45
doImportMethod · 0.45
doSingleImportMethod · 0.45
NormalizeMethod · 0.45
lowerExceptPlaceholdersFunction · 0.45
serversFromPairingsMethod · 0.45
TestAddressStringFunction · 0.45

Calls 1

JoinHostPortMethod · 0.80

Tested by 1

TestAddressStringFunction · 0.36