Moved homepage to it's own go file

This commit is contained in:
2025-05-22 19:26:19 +02:00
parent 3aa166e178
commit d82fd0003b
2 changed files with 22 additions and 17 deletions

22
pages/homepage.go Normal file
View File

@@ -0,0 +1,22 @@
package pages
import (
"html/template"
"net/http"
)
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
}
}

View File

@@ -2,7 +2,6 @@ package pages
import (
"embed"
"html/template"
"net/http"
)
@@ -14,19 +13,3 @@ func InitHttpHandlers() {
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
}
}