From 21e0b088f1ae064b81d220b5d83944471f264abf Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Wed, 2 Oct 2019 19:48:44 +0200 Subject: [PATCH] server: handle nil maintenance service --- server/internal.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/internal.go b/server/internal.go index f2aa728..4aaafba 100644 --- a/server/internal.go +++ b/server/internal.go @@ -59,11 +59,13 @@ func newInternalRouter(s *Server) http.Handler { jsonresponse.NotFound(w, nil) })) internalAPIRouter.Handle("/api/status", http.HandlerFunc(s.statusAPIHandler)) - internalAPIRouter.Handle("/api/maintenance", jsonMethodHandler{ - "GET": http.HandlerFunc(s.maintenanceService.StatusHandler), - "POST": http.HandlerFunc(s.maintenanceService.OnHandler), - "DELETE": http.HandlerFunc(s.maintenanceService.OffHandler), - }) + if s.maintenanceService != nil { + internalAPIRouter.Handle("/api/maintenance", jsonMethodHandler{ + "GET": http.HandlerFunc(s.maintenanceService.StatusHandler), + "POST": http.HandlerFunc(s.maintenanceService.OnHandler), + "DELETE": http.HandlerFunc(s.maintenanceService.OffHandler), + }) + } internalBaseRouter.Handle("/metrics", promhttp.InstrumentMetricHandler( s.metricsRegistry, promhttp.HandlerFor(s.metricsRegistry, promhttp.HandlerOpts{}),