Moved homepage to it's own go file
This commit is contained in:
22
pages/homepage.go
Normal file
22
pages/homepage.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
@@ -2,7 +2,6 @@ package pages
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"html/template"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,19 +13,3 @@ func InitHttpHandlers() {
|
|||||||
http.HandleFunc("/.well-known/autoconfig/mail/config-v1.1.xml", emailAutoconfig)
|
http.HandleFunc("/.well-known/autoconfig/mail/config-v1.1.xml", emailAutoconfig)
|
||||||
http.HandleFunc("/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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user