Add Knative provider
This commit is contained in:
parent
3f23afb2c6
commit
13bcdebc89
38 changed files with 18589 additions and 37 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue