aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/handlers/blog.go
blob: d9955833e13ffbbb40b46b2253439109df223002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package handlers

import (
	"html/template"
	"log"
	"net/http"
)

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
	}

	files := []string{
		"ui/html/base.tmpl.html",
		"ui/html/music_player.tmpl.html",
		"ui/html/pages/index.tmpl.html",
	}

	compiled, err := template.ParseFiles(files...)
	if err != nil {
		ctx.err.Print(err.Error())
		http.Error(w, "Internal Server Error", 500)
		return
	}

	err = compiled.ExecuteTemplate(w, "base", ctx)
	if err != nil {
		ctx.err.Print(err.Error())
		http.Error(w, "Internal Server Error", 500)
		return
	}
}