template lite
parent
933f87d11d
commit
40d5740817
5
http.go
5
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))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue