refactor(ingress): simplify and remove unnecessary variables

This commit is contained in:
Trong Huu Nguyen
2023-10-03 14:21:08 +02:00
parent 92cec63d0c
commit 52331a93db
+1 -10
View File
@@ -60,24 +60,15 @@ func (i *Ingresses) Strings() []string {
}
func (i *Ingresses) MatchingIngress(r *http.Request) (Ingress, bool) {
var match Ingress
found := false
for _, ingress := range i.ingressMap {
hostMatch := ingress.Host() == r.Host || ingress.Host() == r.Header.Get(XForwardedHost)
pathMatch := ingress.Path() == i.MatchingPath(r)
if hostMatch && pathMatch {
match = ingress
found = true
break
return ingress, true
}
}
if found {
return match, true
}
return Ingress{}, false
}