diff --git a/src/cmd/server/handler/handler.go b/src/cmd/server/handler/handler.go index 41018b8..1d5ffd0 100644 --- a/src/cmd/server/handler/handler.go +++ b/src/cmd/server/handler/handler.go @@ -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 diff --git a/src/cmd/server/handler/testdata/index.html b/src/cmd/server/handler/testdata/index.html new file mode 100644 index 0000000..65ee7da --- /dev/null +++ b/src/cmd/server/handler/testdata/index.html @@ -0,0 +1,9 @@ + +
+
+ +

Hello World

+ + + diff --git a/src/cmd/server/handler/ui.go b/src/cmd/server/handler/ui.go new file mode 100644 index 0000000..83d4fb8 --- /dev/null +++ b/src/cmd/server/handler/ui.go @@ -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 +}