1
0
Fork 0

Add Knative provider

This commit is contained in:
idurgakalyan 2025-10-08 01:32:05 -07:00 committed by GitHub
parent 3f23afb2c6
commit 13bcdebc89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 18589 additions and 37 deletions

View file

@ -286,13 +286,13 @@ func (m *Manager) getWRRServiceHandler(ctx context.Context, serviceName string,
}
func (m *Manager) getServiceHandler(ctx context.Context, service dynamic.WRRService) (http.Handler, error) {
switch {
case service.Status != nil:
if service.Status != nil {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(*service.Status)
}), nil
}
case service.GRPCStatus != nil:
if service.GRPCStatus != nil {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
st := status.New(service.GRPCStatus.Code, service.GRPCStatus.Msg)
@ -307,10 +307,24 @@ func (m *Manager) getServiceHandler(ctx context.Context, service dynamic.WRRServ
_, _ = rw.Write(body)
}), nil
default:
return m.BuildHTTP(ctx, service.Name)
}
svcHandler, err := m.BuildHTTP(ctx, service.Name)
if err != nil {
return nil, fmt.Errorf("building HTTP service: %w", err)
}
if service.Headers != nil {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
for k, v := range service.Headers {
req.Header.Set(k, v)
}
svcHandler.ServeHTTP(rw, req)
}), nil
}
return svcHandler, nil
}
func (m *Manager) getHRWServiceHandler(ctx context.Context, serviceName string, config *dynamic.HighestRandomWeight) (http.Handler, error) {