template lite

master
Bel LaPointe 2023-04-07 12:21:53 -06:00
parent 933f87d11d
commit 40d5740817
2 changed files with 15 additions and 2 deletions

View File

@ -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))
}

View File

@ -1 +1,11 @@
hi
<!DOCTYPE html>
<html>
<header>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
</header>
<body>
{{USER}}
</body>
<footer>
</footer>
</html>