diff --git a/plugin/manager.go b/plugin/manager.go index f1631439..18843bc1 100644 --- a/plugin/manager.go +++ b/plugin/manager.go @@ -195,10 +195,12 @@ func (m *manager) Register(syncer syncertypes.Base) error { defer m.m.Unlock() if int, ok := syncer.(Interceptor); ok { - if _, ok := m.interceptors[int.Config().HandlerName]; ok { - return fmt.Errorf("could not add the interceptor %s because the handler name %s is already in use", int.Name(), int.Config().HandlerName) + for _, rule := range int.InterceptedRequests() { + if _, ok := m.interceptors[rule.HandlerName]; ok { + return fmt.Errorf("could not add the interceptor %s because the handler name %s is already in use", int.Name(), rule.HandlerName) + } + m.interceptors[rule.HandlerName] = int } - m.interceptors[int.Config().HandlerName] = int.Handler() } else { m.syncers = append(m.syncers, syncer) } @@ -217,14 +219,14 @@ func (m *manager) Start() error { func (m *manager) startInterceptors() error { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - handlerName := r.Header.Get("Vcluster-Plugin-Handler-Name") + handlerName := r.Header.Get("VCluster-Plugin-Handler-Name") if handlerName == "" { - responsewriters.InternalError(w, r, errors.New("header Vcluster-Plugin-Handler-Name wasn't set")) + responsewriters.InternalError(w, r, errors.New("header VCluster-Plugin-Handler-Name wasn't set")) return } interceptorHandler, ok := m.interceptors[handlerName] if !ok { - responsewriters.InternalError(w, r, errors.New("header Vcluster-Plugin-Handler-Name had no match")) + responsewriters.InternalError(w, r, errors.New("header VCluster-Plugin-Handler-Name had no match")) return } interceptorHandler.ServeHTTP(w, r)