From e991cc2a3b59ea26f85b428fc7aef9b7273ae3b6 Mon Sep 17 00:00:00 2001 From: Musixal Date: Thu, 10 Oct 2024 00:33:23 +0330 Subject: [PATCH] fix: remove data handler when sniffer is off --- internal/web/sniffer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/web/sniffer.go b/internal/web/sniffer.go index 6dac8a7..f5dac22 100644 --- a/internal/web/sniffer.go +++ b/internal/web/sniffer.go @@ -71,10 +71,11 @@ func NewDataStore(listenAddr string, shutdownCtx context.Context, snifferLog str func (m *Usage) Monitor() { mux := http.NewServeMux() - mux.HandleFunc("/", m.handleIndex) // handle index - mux.HandleFunc("/data", m.handleData) // New route for JSON data + mux.HandleFunc("/", m.handleIndex) // handle index mux.HandleFunc("/stats", m.statsHandler) - + if m.sniffer { + mux.HandleFunc("/data", m.handleData) // New route for JSON data + } m.server = &http.Server{ Addr: m.listenAddr, Handler: mux,