Implement shared template layout system
This commit is contained in:
parent
3be7fb76e7
commit
08b669fd8f
9 changed files with 69 additions and 45 deletions
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type Server struct {
|
||||
tmpl *template.Template
|
||||
tmpl map[string]*template.Template
|
||||
s *store.Store
|
||||
http.Handler
|
||||
}
|
||||
|
|
@ -19,13 +19,13 @@ func (h *Server) Close() {
|
|||
func (h *Server) loadHandler() {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.HandleFunc("GET /order/", h.render(h.order, "order.html"))
|
||||
mux.HandleFunc("GET /order/", h.render(h.order, "order"))
|
||||
mux.HandleFunc("GET /", h.redirect("/orders", http.StatusSeeOther))
|
||||
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"))
|
||||
mux.HandleFunc("POST /cake/", h.render(h.postCake, "confirmation.html"))
|
||||
mux.HandleFunc("GET /orders", h.render(h.orders, "orders"))
|
||||
mux.HandleFunc("POST /order/", h.render(h.postOrder, "confirmation"))
|
||||
mux.HandleFunc("GET /cakes", h.render(h.cakes, "cakes"))
|
||||
mux.HandleFunc("GET /cake/", h.render(h.cake, "cake"))
|
||||
mux.HandleFunc("POST /cake/", h.render(h.postCake, "confirmation"))
|
||||
|
||||
h.Handler = mux
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue