1
0
Fork 0

Support invalid HTTPRoute status

Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
Kevin Pollet 2024-05-22 17:20:04 +02:00 committed by GitHub
parent 7fdb1ff8af
commit 0e215f9b61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 361 additions and 297 deletions

View file

@ -222,6 +222,14 @@ func (m *Manager) getWRRServiceHandler(ctx context.Context, serviceName string,
balancer := wrr.New(config.Sticky, config.HealthCheck != nil)
for _, service := range shuffle(config.Services, m.rand) {
if service.Status != nil {
serviceHandler := http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(*service.Status)
})
balancer.Add(service.Name, serviceHandler, service.Weight)
continue
}
serviceHandler, err := m.BuildHTTP(ctx, service.Name)
if err != nil {
return nil, err