From fe057a1c47fff23ed65983f9b8ab8a3fa3cd3f86 Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Tue, 22 Oct 2024 17:11:31 +0300 Subject: [PATCH] Determines http/s automatically --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index cdadde4..4edc348 100644 --- a/main.go +++ b/main.go @@ -232,10 +232,16 @@ func statusHandler(config Config, w http.ResponseWriter, r *http.Request) { // Prepare the endpoint status map endpointStatuses := make(map[string]string) + // Determine protocol based on SSL config + protocol := "http" + if config.SSLcert != "" && config.SSLkey != "" { + protocol = "https" + } + // Check if each endpoint is available or not endpoints := []string{"nginx", "prosody", "jicofo", "jvb", "jibri"} for _, endpoint := range endpoints { - endpointURL := fmt.Sprintf("http://localhost:%d/%s", config.AgentPort, endpoint) + endpointURL := fmt.Sprintf("%s://localhost:%d/%s", protocol, config.AgentPort, endpoint) resp, err := http.Get(endpointURL) if err != nil { endpointStatuses[endpoint] = "not available"