From 544c750072ed7c1342c5ce36443029140e168973 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sat, 17 Oct 2020 10:26:52 +0100
Subject: [PATCH] Version the API endpoint path

---
 cmd/reports-collector/main.go | 2 +-
 collector.go                  | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/cmd/reports-collector/main.go b/cmd/reports-collector/main.go
index 2acd95e..7663120 100644
--- a/cmd/reports-collector/main.go
+++ b/cmd/reports-collector/main.go
@@ -25,7 +25,7 @@ func main() {
 
 	// Create the http.Server.
 	mux := http.NewServeMux()
-	mux.Handle("/ingest", collector)
+	mux.Handle("/ingest/v1", collector)
 	server := &http.Server{
 		Addr:         *addr,
 		Handler:      mux,
diff --git a/collector.go b/collector.go
index 262788f..6ebdc88 100644
--- a/collector.go
+++ b/collector.go
@@ -31,10 +31,6 @@ func NewCollector(sink Sink, handlers ...Handler) *Collector {
 }
 
 func (c *Collector) ServeHTTP(w http.ResponseWriter, req *http.Request) {
-	if req.URL.Path != "/" {
-		http.NotFound(w, req)
-		return
-	}
 	if req.Method != http.MethodPost {
 		http.Error(w, "Bad method", http.StatusMethodNotAllowed)
 		return
-- 
GitLab