Rename orders page template and add debug logging

This commit is contained in:
bronku 2025-03-29 06:30:56 +01:00
parent fe703a9b1c
commit 3be7fb76e7
4 changed files with 4 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import (
)
func (h *Server) orders(r *http.Request) (any, int, error) {
//r.URL.Query().Get()
data, err := h.s.GetOrders()
return data, http.StatusOK, err
}

View file

@ -40,6 +40,7 @@ func (h *Server) postOrder(r *http.Request) (any, int, error) {
}
err = r.ParseForm()
fmt.Println(r.PostForm)
if err != nil {
return nil, http.StatusBadRequest, err
}
@ -75,5 +76,6 @@ func (h *Server) postOrder(r *http.Request) (any, int, error) {
n.Status = strings.TrimSpace(r.FormValue("status"))
n.ID, err = h.s.SaveOrder(n)
fmt.Println(n)
return n, http.StatusAccepted, err
}

View file

@ -21,7 +21,7 @@ func (h *Server) loadHandler() {
mux.HandleFunc("GET /order/", h.render(h.order, "order.html"))
mux.HandleFunc("GET /", h.redirect("/orders", http.StatusSeeOther))
mux.HandleFunc("GET /orders", h.render(h.orders, "index.html"))
mux.HandleFunc("GET /orders", h.render(h.orders, "orders.html"))
mux.HandleFunc("POST /order/", h.render(h.postOrder, "confirmation.html"))
mux.HandleFunc("GET /cakes", h.render(h.cakes, "cakes.html"))
mux.HandleFunc("GET /cake/", h.render(h.cake, "cake.html"))