feat(P1): web foundation — main.go, server.go, HTMX vendored, base+home templates (REQ-040)

Go 1.22 net/http.ServeMux + html/template + http.FileServer for static.
HTMX 2.0.10 vendored as web/static/htmx.min.js (NOT go get; G-006).
base.html layout with nav to all 5 screens. home.html overview.

---ci---
project: oy
phase: 1
milestone: v0.6
status: execute
---/ci---
This commit is contained in:
2026-08-18 13:43:53 +00:00
parent 9811aaabbb
commit 4166de5a4b
6 changed files with 184 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
package main
import (
"html/template"
"log"
"net/http"
"os"
)
func runServer() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
tmpl, err := template.ParseGlob("web/templates/*.html")
if err != nil {
log.Fatalf("parse templates: %v", err)
}
mux := http.NewServeMux()
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := tmpl.ExecuteTemplate(w, "home.html", nil); err != nil {
log.Printf("render home: %v", err)
}
})
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
srv := &http.Server{Addr: ":" + port, Handler: mux}
log.Printf("OpenYield web on :%s", port)
if err := srv.ListenAndServe(); err != nil {
log.Fatalf("server: %v", err)
}
}