From 3e9aba6cbbff44de587e96f3ac418acc0e7d58b0 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Wed, 14 Oct 2020 19:25:50 -0400 Subject: [PATCH] Wrap /api/v1/results handler with security handler if security config is valid (#8) --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 34a81229..86c6d726 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "bytes" "compress/gzip" "github.com/TwinProduction/gatus/config" + "github.com/TwinProduction/gatus/security" "github.com/TwinProduction/gatus/watchdog" "github.com/prometheus/client_golang/prometheus/promhttp" "log" @@ -23,7 +24,11 @@ var ( func main() { cfg := loadConfiguration() - http.HandleFunc("/api/v1/results", serviceResultsHandler) + resultsHandler := serviceResultsHandler + if cfg.Security != nil && cfg.Security.IsValid() { + resultsHandler = security.Handler(serviceResultsHandler, cfg.Security) + } + http.HandleFunc("/api/v1/results", resultsHandler) http.HandleFunc("/health", healthHandler) http.Handle("/", GzipHandler(http.FileServer(http.Dir("./static")))) if cfg.Metrics {