summaryrefslogtreecommitdiffstats
path: root/cmd/web/handlers.go
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-02-11 20:47:15 +0000
committerMatthew Lemon <y@yulqen.org>2024-02-11 20:47:15 +0000
commit47c2880467d1906c9a40746da4bf7c212634db79 (patch)
treedd897564eb6dfd0fd1e878bcf9029d3f8464318f /cmd/web/handlers.go
parent21ec508717ecd6112984b56ca376ebac11477a2a (diff)
Adds an operations html template
Does not contain any dynamic data at this point, i.e. does not actually list the operations from the database - just dummy data at this point.
Diffstat (limited to 'cmd/web/handlers.go')
-rw-r--r--cmd/web/handlers.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go
index 78d4029..49f52ca 100644
--- a/cmd/web/handlers.go
+++ b/cmd/web/handlers.go
@@ -12,14 +12,27 @@ 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
+ // }
+ files := []string{
+ "./ui/html/base.tmpl.html",
+ "./ui/html/pages/operations/list.tmpl.html",
+ "./ui/html/partials/nav.tmpl.html",
+ }
+
+ ts, err := template.ParseFiles(files...)
if err != nil {
- app.serverError(w, r, err)
+ app.serverError(w, r, err) // Use the serverError() helper
return
}
- for _, op := range ops {
- fmt.Fprintf(w, "%+v\n", op)
+ err = ts.ExecuteTemplate(w, "base", nil)
+ if err != nil {
+ app.serverError(w, r, err) // Use the serverError() helper
}
}