From 92fa325fd5fad0e582e2f4c2744db16b8e23a988 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Tue, 20 Jun 2023 16:59:39 +0100 Subject: [PATCH] Add domains compile after put and delete api call --- servers/api.go | 2 ++ servers/conf.go | 1 + utils/response.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/servers/api.go b/servers/api.go index 60a3fe3..51f4150 100644 --- a/servers/api.go +++ b/servers/api.go @@ -38,6 +38,7 @@ func NewApiServer(conf *Conf, compileTarget utils.MultiCompilable) *http.Server // add domain with active state q := req.URL.Query() conf.Domains.Put(params.ByName("domain"), q.Get("active") == "1") + conf.Domains.Compile() }) r.DELETE("/domain/:domain", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) { if !hasPerms(conf.Verify, req, "violet:domains") { @@ -48,6 +49,7 @@ func NewApiServer(conf *Conf, compileTarget utils.MultiCompilable) *http.Server // add domain with active state q := req.URL.Query() conf.Domains.Put(params.ByName("domain"), q.Get("active") == "1") + conf.Domains.Compile() }) // Endpoint for acme-challenge diff --git a/servers/conf.go b/servers/conf.go index f6f738d..b6fd22d 100644 --- a/servers/conf.go +++ b/servers/conf.go @@ -29,6 +29,7 @@ type DomainProvider interface { IsValid(host string) bool Put(domain string, active bool) Delete(domain string) + Compile() } type AcmeChallengeProvider interface { diff --git a/utils/response.go b/utils/response.go index 4a54287..48eb158 100644 --- a/utils/response.go +++ b/utils/response.go @@ -7,7 +7,7 @@ import ( // RespondHttpStatus outputs the status code and text using http.Error() func RespondHttpStatus(rw http.ResponseWriter, status int) { - http.Error(rw, fmt.Sprintf("%d %s\n", status, http.StatusText(status)), status) + http.Error(rw, fmt.Sprintf("%d %s", status, http.StatusText(status)), status) } func RespondVioletError(rw http.ResponseWriter, status int, msg string) {