summaryrefslogtreecommitdiffstats
path: root/cmd/web/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web/handlers.go')
-rw-r--r--cmd/web/handlers.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 49f52ca..40ca509 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"html/template"
+ "log"
"net/http"
"strconv"
@@ -12,12 +13,12 @@ import (
func (app *application) listOperations(w http.ResponseWriter, r *http.Request) {
- // ops, err := app.operations.ListAll()
+ ops, err := app.operations.ListAll()
- // if err != nil {
- // app.serverError(w, r, err)
- // return
- // }
+ if err != nil {
+ app.serverError(w, r, err)
+ return
+ }
files := []string{
"./ui/html/base.tmpl.html",
"./ui/html/pages/operations/list.tmpl.html",
@@ -30,7 +31,12 @@ func (app *application) listOperations(w http.ResponseWriter, r *http.Request) {
return
}
- err = ts.ExecuteTemplate(w, "base", nil)
+ data := operationsTemplateData{
+ Operations: ops,
+ }
+ log.Println(data)
+
+ err = ts.ExecuteTemplate(w, "base", data)
if err != nil {
app.serverError(w, r, err) // Use the serverError() helper
}