diff options
author | Samuel Johnson <[email protected]> | 2025-02-10 02:19:21 -0500 |
---|---|---|
committer | Samuel Johnson <[email protected]> | 2025-02-10 02:19:21 -0500 |
commit | 9de239a9badbbc075f1cc8079a6435f0780e5d26 (patch) | |
tree | 559f29f7c3a0213a4fd712f4f325f5f820e6ca79 /cmd/web/handlers/blog.go |
But it was a beginningtrunk
Diffstat (limited to 'cmd/web/handlers/blog.go')
-rw-r--r-- | cmd/web/handlers/blog.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/web/handlers/blog.go b/cmd/web/handlers/blog.go new file mode 100644 index 0000000..5a874f4 --- /dev/null +++ b/cmd/web/handlers/blog.go @@ -0,0 +1,32 @@ +package handlers + +import ( + "html/template" + "log" + "net/http" +) + +func (ctx *HandlerContext) blogIndex(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/" { + http.NotFound(w, r) + return + } + + files := []string{ + "./ui/html/base.tmpl.html", + "./ui/html/pages/index.tmpl.html", + } + + compiled, err := template.ParseFiles(files...) + if err != nil { + log.Println(err.Error()) + http.Error(w, "Internal Server Error", 500) + return + } + + err = compiled.ExecuteTemplate(w, "base", ctx) + if err != nil { + log.Println(err.Error()) + http.Error(w, "Internal Server Error", 500) + } +} |