diff --git a/alerts/alerts_test.go b/alerts/alerts_test.go index 24b299e1b..99b698f7e 100644 --- a/alerts/alerts_test.go +++ b/alerts/alerts_test.go @@ -57,7 +57,7 @@ func TestWebhooks(t *testing.T) { mux := http.NewServeMux() var events []webhooks.Event var mu sync.Mutex - mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/event", func(w http.ResponseWriter, r *http.Request) { var event webhooks.Event if err := json.NewDecoder(r.Body).Decode(&event); err != nil { t.Fatal(err) @@ -72,7 +72,7 @@ func TestWebhooks(t *testing.T) { // register a hook wh := webhooks.Webhook{ Module: webhookModule, - URL: fmt.Sprintf("http://%v/events", srv.Listener.Addr().String()), + URL: fmt.Sprintf("http://%v/event", srv.Listener.Addr().String()), } if hookID := wh.String(); hookID != fmt.Sprintf("%v.%v.%v", wh.URL, wh.Module, "") { t.Fatalf("wrong result for wh.String(): %v != %v", wh.String(), hookID) diff --git a/internal/worker/events_test.go b/internal/worker/events_test.go index 76c89bbfb..cab65c62d 100644 --- a/internal/worker/events_test.go +++ b/internal/worker/events_test.go @@ -117,7 +117,7 @@ func TestEventSubscriber(t *testing.T) { } // setup a server - mux := jape.Mux(map[string]jape.Handler{"POST /events": func(jc jape.Context) { + mux := jape.Mux(map[string]jape.Handler{"POST /event": func(jc jape.Context) { var event webhooks.Event if jc.Decode(&event) != nil { return @@ -132,7 +132,7 @@ func TestEventSubscriber(t *testing.T) { defer srv.Close() // register the subscriber - eventsURL := fmt.Sprintf("http://%v/events", srv.Listener.Addr().String()) + eventsURL := fmt.Sprintf("http://%v/event", srv.Listener.Addr().String()) go func() { if err := s.Register(context.Background(), eventsURL); err != nil { t.Error(err) diff --git a/worker/client/client.go b/worker/client/client.go index 9abac4d0e..8996f66ae 100644 --- a/worker/client/client.go +++ b/worker/client/client.go @@ -271,7 +271,7 @@ func (c *Client) UploadStats() (resp api.UploadStatsResponse, err error) { // NotifyEvent notifies the worker of an event. func (c *Client) NotifyEvent(ctx context.Context, e webhooks.Event) (err error) { - err = c.c.WithContext(ctx).POST("/events", e, nil) + err = c.c.WithContext(ctx).POST("/event", e, nil) return } diff --git a/worker/worker.go b/worker/worker.go index 111300ff2..ebb7283a7 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -1165,7 +1165,7 @@ func (w *Worker) accountHandlerGET(jc jape.Context) { jc.Encode(account) } -func (w *Worker) eventsHandlerPOST(jc jape.Context) { +func (w *Worker) eventHandlerPOST(jc jape.Context) { var event webhooks.Event if jc.Decode(&event) != nil { return @@ -1251,7 +1251,7 @@ func (w *Worker) Handler() http.Handler { "GET /account/:hostkey": w.accountHandlerGET, "GET /id": w.idHandlerGET, - "POST /events": w.eventsHandlerPOST, + "POST /event": w.eventHandlerPOST, "GET /memory": w.memoryGET, @@ -1283,7 +1283,7 @@ func (w *Worker) Handler() http.Handler { // Setup register event webhooks that enable the worker cache. func (w *Worker) Setup(ctx context.Context, apiURL, apiPassword string) error { go func() { - eventsURL := fmt.Sprintf("%s/events", apiURL) + eventsURL := fmt.Sprintf("%s/event", apiURL) webhookOpts := []webhooks.HeaderOption{webhooks.WithBasicAuth("", apiPassword)} if err := w.eventSubscriber.Register(w.shutdownCtx, eventsURL, webhookOpts...); err != nil { w.logger.Errorw("failed to register webhooks", zap.Error(err))