From ada3b4ad1356526a009ade9ac7fc55d6f9b5296c Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 2 Oct 2018 10:10:53 +0200 Subject: [PATCH] draft of a panel --- cmd/userpanel/main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/userpanel/main.go b/cmd/userpanel/main.go index 40b9a1d..084e531 100644 --- a/cmd/userpanel/main.go +++ b/cmd/userpanel/main.go @@ -2,11 +2,21 @@ package main import ( "fmt" + "html/template" "net/http" "github.com/urfave/negroni" ) +var helloTmpl *template.Template + +func init() { + helloTmpl = template.Must(template.New("hello").Parse(` +Hello, {{.User}} +

Go to Feed Reader

+`)) +} + func main() { mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -15,7 +25,8 @@ func main() { panic("Authentication middleware failed!") } w.WriteHeader(200) - fmt.Fprintf(w, "Hello, %s\n", user) + w.Header().Set("Content-type", "text/html") + helloTmpl.Execute(w, map[string]interface{}{"User": user}) }) ha := HeaderAuth{AllowedNames: []string{"feedati-fe"}, RequireUser: true}