diff --git a/17-results-summary-component-go/main.go b/17-results-summary-component-go/main.go index c098df2..0bc4006 100644 --- a/17-results-summary-component-go/main.go +++ b/17-results-summary-component-go/main.go @@ -2,6 +2,7 @@ package main import ( "embed" + "html/template" "io" "log" "net/http" @@ -14,10 +15,16 @@ var publicContent embed.FS func main() { // visible on http://localhost:8080/static/public/some-text.txt http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(publicContent)))) - http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { + + http.HandleFunc("/hello", func(w http.ResponseWriter, req *http.Request) { io.WriteString(w, "This is temporary here, hello") }) + http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { + tmpl := template.Must(template.ParseFiles("templates/summary-component.gohtml")) + tmpl.Execute(w, nil) + }) + log.Print("starting server on default :8080") log.Fatal(http.ListenAndServe(":8080", nil)) } diff --git a/17-results-summary-component-go/templates/summary-component.gohtml b/17-results-summary-component-go/templates/summary-component.gohtml new file mode 100644 index 0000000..88bf0f2 --- /dev/null +++ b/17-results-summary-component-go/templates/summary-component.gohtml @@ -0,0 +1,16 @@ + + + + + + + HTML5 Boilerplate + + + + +

Page Title

+ + + +