mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-18 06:29:42 +02:00
fix(route): handle synthetic load balancer routes consistently
Synthetic load balancer routes were created with SchemeNone and a zero proxy port, so the embedded Route logic treated them as excluded routes. That caused them to be keyed like excluded routes instead of by alias, which broke HTTP route lookup in reverse proxy load balancer tests. Override Key and ShouldExclude for synthetic load balancer routes so they stay addressable through the HTTP route pool while preserving the existing behavior for normal backend routes. Also guard addToLoadBalancer against a nil Homepage on an existing linked route, and update the reverse proxy test to use the in-memory test entrypoint rather than depending on real listener setup.
This commit is contained in:
@@ -123,6 +123,24 @@ func (r *ReverseProxyRoute) ReverseProxy() *reverseproxy.ReverseProxy {
|
||||
return r.rp
|
||||
}
|
||||
|
||||
func (r *ReverseProxyRoute) isSyntheticLoadBalancerRoute() bool {
|
||||
return r.loadBalancer != nil && r.rp == nil
|
||||
}
|
||||
|
||||
func (r *ReverseProxyRoute) Key() string {
|
||||
if r.isSyntheticLoadBalancerRoute() {
|
||||
return r.Alias
|
||||
}
|
||||
return r.Route.Key()
|
||||
}
|
||||
|
||||
func (r *ReverseProxyRoute) ShouldExclude() bool {
|
||||
if r.isSyntheticLoadBalancerRoute() {
|
||||
return false
|
||||
}
|
||||
return r.Route.ShouldExclude()
|
||||
}
|
||||
|
||||
// Start implements task.TaskStarter.
|
||||
func (r *ReverseProxyRoute) Start(parent task.Parent) error {
|
||||
r.task = parent.Subtask("http."+r.Name(), false)
|
||||
@@ -206,7 +224,7 @@ func (r *ReverseProxyRoute) addToLoadBalancer(parent task.Parent, ep entrypoint.
|
||||
linked = l.(*ReverseProxyRoute) // it must be a reverse proxy route
|
||||
lb = linked.loadBalancer
|
||||
lb.UpdateConfigIfNeeded(cfg)
|
||||
if linked.Homepage.Name == "" {
|
||||
if linked.Homepage == nil || linked.Homepage.Name == "" {
|
||||
linked.Homepage = r.Homepage
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user