Initial commit

This commit is contained in:
2025-05-22 18:08:15 +02:00
commit 364ffa15de
33 changed files with 900 additions and 0 deletions

32
pages/init.go Normal file
View File

@@ -0,0 +1,32 @@
package pages
import (
"embed"
"html/template"
"net/http"
)
//go:embed templates/*
var content embed.FS
func InitHttpHandlers() {
http.HandleFunc("/{$}", homepage)
http.HandleFunc("/.well-known/autoconfig/mail/config-v1.1.xml", emailAutoconfig)
http.HandleFunc("/mail/config-v1.1.xml", emailAutoconfig)
}
func homepage(w http.ResponseWriter, r *http.Request) {
templateFile := "templates/homepage.tmpl"
files, err := template.New(templateFile).ParseFS(content, templateFile)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = files.ExecuteTemplate(w, "homepage.tmpl", nil)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}