@@ -536,7 +536,7 @@ func (st *ServerType) serversFromPairings(
536536 if k == j {
537537 continue
538538 }
539- if sliceContains (sblock2 .block .GetKeysText (), key ) {
539+ if slices . Contains (sblock2 .block .GetKeysText (), key ) {
540540 return nil , fmt .Errorf ("ambiguous site definition: %s" , key )
541541 }
542542 }
@@ -720,7 +720,7 @@ func (st *ServerType) serversFromPairings(
720720 if srv .AutoHTTPS == nil {
721721 srv .AutoHTTPS = new (caddyhttp.AutoHTTPSConfig )
722722 }
723- if ! sliceContains (srv .AutoHTTPS .Skip , addr .Host ) {
723+ if ! slices . Contains (srv .AutoHTTPS .Skip , addr .Host ) {
724724 srv .AutoHTTPS .Skip = append (srv .AutoHTTPS .Skip , addr .Host )
725725 }
726726 }
@@ -734,7 +734,7 @@ func (st *ServerType) serversFromPairings(
734734 // https://caddy.community/t/making-sense-of-auto-https-and-why-disabling-it-still-serves-https-instead-of-http/9761
735735 createdTLSConnPolicies , ok := sblock .pile ["tls.connection_policy" ]
736736 hasTLSEnabled := (ok && len (createdTLSConnPolicies ) > 0 ) ||
737- (addr .Host != "" && srv .AutoHTTPS != nil && ! sliceContains (srv .AutoHTTPS .Skip , addr .Host ))
737+ (addr .Host != "" && srv .AutoHTTPS != nil && ! slices . Contains (srv .AutoHTTPS .Skip , addr .Host ))
738738
739739 // we'll need to remember if the address qualifies for auto-HTTPS, so we
740740 // can add a TLS conn policy if necessary
@@ -1061,7 +1061,7 @@ func consolidateConnPolicies(cps caddytls.ConnectionPolicies) (caddytls.Connecti
10611061 } else if cps [i ].CertSelection != nil && cps [j ].CertSelection != nil {
10621062 // if both have one, then combine AnyTag
10631063 for _ , tag := range cps [j ].CertSelection .AnyTag {
1064- if ! sliceContains (cps [i ].CertSelection .AnyTag , tag ) {
1064+ if ! slices . Contains (cps [i ].CertSelection .AnyTag , tag ) {
10651065 cps [i ].CertSelection .AnyTag = append (cps [i ].CertSelection .AnyTag , tag )
10661066 }
10671067 }
@@ -1144,7 +1144,7 @@ func appendSubrouteToRouteList(routeList caddyhttp.RouteList,
11441144func buildSubroute (routes []ConfigValue , groupCounter counter , needsSorting bool ) (* caddyhttp.Subroute , error ) {
11451145 if needsSorting {
11461146 for _ , val := range routes {
1147- if ! directiveIsOrdered ( val .directive ) {
1147+ if ! slices . Contains ( directiveOrder , val .directive ) {
11481148 return nil , fmt .Errorf ("directive '%s' is not an ordered HTTP handler, so it cannot be used here - try placing within a route block or using the order global option" , val .directive )
11491149 }
11501150 }
@@ -1354,17 +1354,8 @@ func (st *ServerType) compileEncodedMatcherSets(sblock serverBlock) ([]caddy.Mod
13541354
13551355 // add this server block's keys to the matcher
13561356 // pair if it doesn't already exist
1357- if addr .Host != "" {
1358- var found bool
1359- for _ , h := range chosenMatcherPair .hostm {
1360- if h == addr .Host {
1361- found = true
1362- break
1363- }
1364- }
1365- if ! found {
1366- chosenMatcherPair .hostm = append (chosenMatcherPair .hostm , addr .Host )
1367- }
1357+ if addr .Host != "" && ! slices .Contains (chosenMatcherPair .hostm , addr .Host ) {
1358+ chosenMatcherPair .hostm = append (chosenMatcherPair .hostm , addr .Host )
13681359 }
13691360 }
13701361
@@ -1540,16 +1531,6 @@ func tryDuration(val any, warnings *[]caddyconfig.Warning) caddy.Duration {
15401531 return durationVal
15411532}
15421533
1543- // sliceContains returns true if needle is in haystack.
1544- func sliceContains (haystack []string , needle string ) bool {
1545- for _ , s := range haystack {
1546- if s == needle {
1547- return true
1548- }
1549- }
1550- return false
1551- }
1552-
15531534// listenersUseAnyPortOtherThan returns true if there are any
15541535// listeners in addresses that use a port which is not otherPort.
15551536// Mostly borrowed from unexported method in caddyhttp package.
0 commit comments