Add domains compile after put and delete api call

This commit is contained in:
Melon 2023-06-20 16:59:39 +01:00
parent 629057edc3
commit 92fa325fd5
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
3 changed files with 4 additions and 1 deletions

View File

@ -38,6 +38,7 @@ func NewApiServer(conf *Conf, compileTarget utils.MultiCompilable) *http.Server
// add domain with active state // add domain with active state
q := req.URL.Query() q := req.URL.Query()
conf.Domains.Put(params.ByName("domain"), q.Get("active") == "1") 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) { r.DELETE("/domain/:domain", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
if !hasPerms(conf.Verify, req, "violet:domains") { 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 // add domain with active state
q := req.URL.Query() q := req.URL.Query()
conf.Domains.Put(params.ByName("domain"), q.Get("active") == "1") conf.Domains.Put(params.ByName("domain"), q.Get("active") == "1")
conf.Domains.Compile()
}) })
// Endpoint for acme-challenge // Endpoint for acme-challenge

View File

@ -29,6 +29,7 @@ type DomainProvider interface {
IsValid(host string) bool IsValid(host string) bool
Put(domain string, active bool) Put(domain string, active bool)
Delete(domain string) Delete(domain string)
Compile()
} }
type AcmeChallengeProvider interface { type AcmeChallengeProvider interface {

View File

@ -7,7 +7,7 @@ import (
// RespondHttpStatus outputs the status code and text using http.Error() // RespondHttpStatus outputs the status code and text using http.Error()
func RespondHttpStatus(rw http.ResponseWriter, status int) { 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) { func RespondVioletError(rw http.ResponseWriter, status int, msg string) {