from / to /ui for multipage transition
parent
fffa48d9ad
commit
1fcd1e28dc
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
../../ui/index.html
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../ui/
|
||||
Loading…
Reference in New Issue