added logging
This commit is contained in:
parent
a408e1487d
commit
980503ac31
6 changed files with 9 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func AboutHandler(content embed.FS) http.HandlerFunc {
|
||||
log.Print("AboutHandler called")
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(content, "templates/base.html", "templates/header.html", "templates/main.html", "templates/footer.html", "templates/about.html")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ package handlers
|
|||
|
||||
import (
|
||||
"ddServer/model"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func AddMonster(Monsters *[]model.Monster) http.HandlerFunc {
|
||||
log.Print("AddMonster called")
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO
|
||||
if r.Method != http.MethodPost {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func ContactHandler(content embed.FS) http.HandlerFunc {
|
||||
log.Print("ContactHandler called")
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(content, "templates/base.html", "templates/header.html", "templates/main.html", "templates/footer.html", "templates/about.html", "templates/contact.html")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func FormHandler(content embed.FS, filename string) http.HandlerFunc {
|
||||
log.Print("FormHandler called")
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFS(content, "templates/base.html", "templates/header.html", "templates/main.html", "templates/footer.html", "templates/monsterForm.html")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"embed"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
|
|
@ -14,6 +15,7 @@ var mu sync.Mutex
|
|||
|
||||
// submitHandler verarbeitet die Formulardaten
|
||||
func SubmitHandler(content embed.FS, chars *[]model.Character, Monsters *[]model.Monster, filename string) http.HandlerFunc {
|
||||
log.Print("SubmitHandler called")
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -4,7 +4,7 @@ import (
|
|||
"ddServer/handlers"
|
||||
"ddServer/model"
|
||||
"embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
|
@ -28,6 +28,6 @@ func main() {
|
|||
http.HandleFunc("/about", handlers.AboutHandler(content))
|
||||
http.HandleFunc("/contact", handlers.ContactHandler(content))
|
||||
|
||||
fmt.Println("Server gestartet, erreichbar unter http://localhost:8080")
|
||||
log.Print("Server gestartet, erreichbar unter http://localhost:8080")
|
||||
http.ListenAndServe(":8080", nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue