Wrap /api/v1/results handler with security handler if security config is valid (#8)
This commit is contained in:
parent
3fb7d27f3a
commit
3e9aba6cbb
7
main.go
7
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"github.com/TwinProduction/gatus/config"
|
"github.com/TwinProduction/gatus/config"
|
||||||
|
"github.com/TwinProduction/gatus/security"
|
||||||
"github.com/TwinProduction/gatus/watchdog"
|
"github.com/TwinProduction/gatus/watchdog"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"log"
|
"log"
|
||||||
@ -23,7 +24,11 @@ var (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := loadConfiguration()
|
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.HandleFunc("/health", healthHandler)
|
||||||
http.Handle("/", GzipHandler(http.FileServer(http.Dir("./static"))))
|
http.Handle("/", GzipHandler(http.FileServer(http.Dir("./static"))))
|
||||||
if cfg.Metrics {
|
if cfg.Metrics {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user