package main import ( "fmt" "net/http" "github.com/jboursiquot/go-proverbs" "encoding/json" "log" "html/template" ) type Proverb struct { Saying string `json:"saying"` Link string `json:"link"` } func HandleProverbJson(w http.ResponseWriter, r *http.Request) { randomProverb := proverbs.Random() p := Proverb { Saying: randomProverb.Saying, Link: randomProverb.Link, } err := json.NewEncoder(w).Encode(p) if err != nil { http.Error(w, "uups, da ist etwas schief gegangen!", http.StatusInternalServerError) } } func HandleProverbPage(w http.ResponseWriter, r *http.Request) { t, _ := template.New("page").Parse(`