all repos — flounder @ 360d16a3e1b09f42e4072ca7cd42c98f2db1ef4e

A small site builder for the Gemini protocol

add check domain handler
alex wennerberg alex@alexwennerberg.com
Sat, 09 Jan 2021 17:04:37 -0800
commit

360d16a3e1b09f42e4072ca7cd42c98f2db1ef4e

parent

add182fc510af8887560e8eacc910e379d80f49b

1 files changed, 11 insertions(+), 0 deletions(-)

jump to
M http.gohttp.go

@@ -732,6 +732,14 @@ http.Redirect(w, r, "/admin", http.StatusSeeOther)

} } +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

@@ -760,6 +768,9 @@ serveMux.HandleFunc(hostname+"/logout", logoutHandler)

serveMux.HandleFunc(hostname+"/delete/", deleteFileHandler) 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)