diff --git a/cmd/main.go b/cmd/main.go index b94f5b8..cec7841 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,6 +9,22 @@ import ( var x = 2 func main() { + http.HandleFunc("/data", func(w http.ResponseWriter, req *http.Request) { + w.WriteHeader(200) + const tpl = ` +

Hey check out the data

+ ` + t, err := template.New("default").Parse(tpl) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + err = t.Execute(w, nil) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + }) http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(200) // fmt.Fprintf(w, "Welcome to the home page!") @@ -19,9 +35,14 @@ func main() { {{.Title}} + {{range .Items}}
{{ . }}
{{else}}
no rows
{{end}} + + `