From e935a307c85d3080cc04270472daeed6b63059e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Poniedzia=C5=82ek?= Date: Mon, 29 Jan 2024 11:41:33 +0100 Subject: [PATCH] Restart caddy after adding HSTS --- provisioning/resources/control-plane/main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/provisioning/resources/control-plane/main.go b/provisioning/resources/control-plane/main.go index 5b0e5ef8..3d71ff15 100644 --- a/provisioning/resources/control-plane/main.go +++ b/provisioning/resources/control-plane/main.go @@ -137,10 +137,15 @@ func addHsts(resp http.ResponseWriter, req *http.Request) { err := addHstsHeader(config.ConfigNames.Caddy) if err != nil { http.Error(resp, err.Error(), 500) - } else { - resp.WriteHeader(http.StatusOK) - io.WriteString(resp, "OK") + return } + err, status := restartSPService("caddy") + if err != nil { + http.Error(resp, err.Error(), status) + return + } + resp.WriteHeader(http.StatusOK) + io.WriteString(resp, "OK") } else { // Return 404 for other methods http.Error(resp, "", 404)