temp ui handler

main
Bel LaPointe 2025-04-28 21:45:02 -06:00
parent a59857b549
commit ac642d0bdf
3 changed files with 27 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package handler
import (
"context"
"net/http"
"strings"
)
type Handler struct {
@ -20,10 +21,11 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (h Handler) serveHTTP(w http.ResponseWriter, r *http.Request) error {
switch r.URL.Path {
case "/v1/vpntor":
if strings.HasPrefix(r.URL.Path, "/v1/vpntor") {
return h.vpntor(r.Context(), r.Body)
default:
} else if strings.HasPrefix(r.URL.Path, "/experimental/ui") {
return h.ui(w, r)
} else {
http.NotFound(w, r)
}
return nil

View File

@ -0,0 +1,9 @@
<html>
<header>
</header>
<body>
<h2>Hello World</h2>
</body>
<footer>
</footer>
</html>

View File

@ -0,0 +1,13 @@
package handler
import (
"log"
"net/http"
)
func (h Handler) ui(w http.ResponseWriter, r *http.Request) error {
log.Printf("ui(%s)", r.URL.String())
fs := http.FileServer(http.Dir("./src/cmd/server/handler/testdata"))
http.StripPrefix("/experimental/ui", fs).ServeHTTP(w, r)
return nil
}