Initial commit
This commit is contained in:
32
pages/init.go
Normal file
32
pages/init.go
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user