diff options
Diffstat (limited to 'cmd/web/handlers/blog.go')
-rw-r--r-- | cmd/web/handlers/blog.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd/web/handlers/blog.go b/cmd/web/handlers/blog.go index 5a874f4..da3aec2 100644 --- a/cmd/web/handlers/blog.go +++ b/cmd/web/handlers/blog.go @@ -6,7 +6,13 @@ import ( "net/http" ) -func (ctx *HandlerContext) blogIndex(w http.ResponseWriter, r *http.Request) { +type blogContext struct { + err *log.Logger + + Name string +} + +func (ctx blogContext) index(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return @@ -19,14 +25,14 @@ func (ctx *HandlerContext) blogIndex(w http.ResponseWriter, r *http.Request) { compiled, err := template.ParseFiles(files...) if err != nil { - log.Println(err.Error()) + ctx.err.Print(err.Error()) http.Error(w, "Internal Server Error", 500) return } err = compiled.ExecuteTemplate(w, "base", ctx) if err != nil { - log.Println(err.Error()) + ctx.err.Print(err.Error()) http.Error(w, "Internal Server Error", 500) } } |