from / to /ui for multipage transition

master
bel 2022-02-13 21:50:26 -07:00
parent fffa48d9ad
commit 1fcd1e28dc
3 changed files with 13 additions and 2 deletions

View File

@ -47,6 +47,7 @@ func (server *Server) Routes() error {
wildcard("/api/v0/media"): server.apiV0MediaIDHandler,
wildcards("/api/v0/files"): server.apiV0FilesHandler,
"/api/v0/search": server.apiV0SearchHandler,
wildcards("/ui"): server.uiHandler,
} {
log.Printf("listening for %s", path)
if err := server.router.Add(path, server.tryCatchHttpHandler(handler)); err != nil {
@ -195,8 +196,18 @@ func (server *Server) putContentHandler(filePath string, w http.ResponseWriter,
return ensureAndWrite(filePath, b)
}
func (server *Server) uiHandler(w http.ResponseWriter, r *http.Request) error {
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/ui")
d := path.Join(server.root, "ui")
httpDir := http.Dir(d)
fileServer := http.FileServer(httpDir)
fileServer.ServeHTTP(w, r)
return nil
}
func (server *Server) rootHandler(w http.ResponseWriter, r *http.Request) error {
return server.getContentHandler(path.Join(server.root, "index.html"), w, r)
http.Redirect(w, r, "/ui", 301)
return nil
}
func (server *Server) tree() Tree {

View File

@ -1 +0,0 @@
../../ui/index.html

View File

@ -0,0 +1 @@
../../ui/