Welcome to the Dungeons and Dragons Monster Generator website! We are a team of enthusiasts...
+diff --git a/handlers/main_handler.go b/handlers/main_handler.go new file mode 100644 index 0000000..06a3821 --- /dev/null +++ b/handlers/main_handler.go @@ -0,0 +1,28 @@ +package handlers + +import ( + "embed" + "html/template" + "log" + "net/http" +) + +// MainHandler +func MainHandler(content embed.FS) http.HandlerFunc { + log.Print("MainHandler called") + return func(w http.ResponseWriter, r *http.Request) { + tmpl, err := template.ParseFS(content, "templates/main.html", "templates/monsterForm.html", "templates/monster.html", "templates/monsterTable.html") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + err = tmpl.ExecuteTemplate(w, "main", map[string]interface{}{ + "Title": "Dungeons & Dragons Monster Generator", + }) + if err != nil { + log.Printf("Template execution error: %v\n", err) + http.Error(w, err.Error(), http.StatusInternalServerError) + } + } +} diff --git a/main.go b/main.go index 79d9633..a990799 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,7 @@ func main() { http.HandleFunc("/submit", handlers.SubmitHandler(content, &chars, &Monsters, filename)) http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.FS(content)))) http.HandleFunc("/addMonster", handlers.AddMonster(&Monsters)) + http.HandleFunc("/main", handlers.MainHandler(content)) http.HandleFunc("/about", handlers.AboutHandler(content)) http.HandleFunc("/contact", handlers.ContactHandler(content)) http.HandleFunc("/monsterTable", handlers.MonsterTableHandler(content, &Monsters)) diff --git a/templates/about.html b/templates/about.html index cff355b..9d29c17 100644 --- a/templates/about.html +++ b/templates/about.html @@ -1,2 +1,15 @@ {{ define "about" }} +
About Us
+Welcome to the Dungeons and Dragons Monster Generator website! We are a team of enthusiasts...
+Contact Us
+You can reach us through the following channels:
+