Essayons de passer la page de log en react

This commit is contained in:
2025-09-07 22:08:41 +02:00
parent 70681a8b55
commit fa6ed6ae34
26 changed files with 6607 additions and 17 deletions

35
pmoapp/web.go Normal file
View File

@@ -0,0 +1,35 @@
package pmoapp
import (
"embed"
"io/fs"
"net/http"
)
//go:embed web/dist/*
var AppRoot embed.FS
func Handler(mux *http.ServeMux) {
fsys, _ := fs.Sub(AppRoot, "web/dist")
// /app → page principale
mux.Handle("/app/", http.StripPrefix("/app/", http.FileServer(http.FS(fsys))))
mux.HandleFunc("/app", func(w http.ResponseWriter, r *http.Request) {
index, _ := fs.ReadFile(fsys, "index.html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write(index)
})
// /log → interface log (React)
mux.Handle("/log/", http.StripPrefix("/log/", http.FileServer(http.FS(fsys))))
mux.HandleFunc("/log", func(w http.ResponseWriter, r *http.Request) {
index, _ := fs.ReadFile(fsys, "index.html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Write(index)
})
// / → redirect vers /app
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/app", http.StatusFound)
})
}