flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 360d16a3e1b09f42e4072ca7cd42c98f2db1ef4e
parent add182fc510af8887560e8eacc910e379d80f49b
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  9 Jan 2021 17:04:37 -0800

add check domain handler

Diffstat:
Mhttp.go | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/http.go b/http.go @@ -732,6 +732,14 @@ func adminUserHandler(w http.ResponseWriter, r *http.Request) { } } +func checkDomainHandler(w http.ResponseWriter, r *http.Request) { + domain := r.URL.Query().Get("domain") + if domain != "" && domains[domain] != "" { + w.Write([]byte(domain)) + return + } + http.Error(w, "Not Found", 404) +} func runHTTPServer() { log.Printf("Running http server with hostname %s on port %d.", c.Host, c.HttpPort) var err error @@ -761,6 +769,9 @@ func runHTTPServer() { serveMux.HandleFunc(hostname+"/delete-account", deleteAccountHandler) serveMux.HandleFunc(hostname+"/reset-password", resetPasswordHandler) + // Check domain -- used by caddy + serveMux.HandleFunc(hostname+"/check-domain", checkDomainHandler) + // admin commands serveMux.HandleFunc(hostname+"/admin/user/", adminUserHandler) // TODO authentication