From 40d57408178fa5e97ddde753b087eb795a999fb5 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 7 Apr 2023 12:21:53 -0600 Subject: [PATCH] template lite --- http.go | 5 ++++- public/root.html | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/http.go b/http.go index be42ffb..d552885 100644 --- a/http.go +++ b/http.go @@ -6,6 +6,7 @@ import ( "fmt" "net/http" "os" + "strings" ) type Context struct { @@ -55,9 +56,11 @@ var httpRootHTML string func httpRoot(w http.ResponseWriter, r *http.Request) { body := httpRootHTML - if os.Getenv("DEBUG") { + if os.Getenv("DEBUG") != "" { b, _ := os.ReadFile("public/root.html") body = string(b) } + ctx := extract(r.Context()) + body = strings.ReplaceAll(body, "{{USER}}", ctx.User) w.Write([]byte(body)) } diff --git a/public/root.html b/public/root.html index 45b983b..cb4c160 100644 --- a/public/root.html +++ b/public/root.html @@ -1 +1,11 @@ -hi + + +
+ +
+ + {{USER}} + + +