add check domain handler
alex wennerberg alex@alexwennerberg.com
Sat, 09 Jan 2021 17:04:37 -0800
1 files changed,
11 insertions(+),
0 deletions(-)
jump to
M
http.go
→
http.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)