Move web UI from /ui/ to /web/ path prefix

The web UI is now mounted at /web/ (previously /ui/) — cmd/server/main.go
wraps web.Server.Handler with http.StripPrefix("/web", ...), so
internal/web's own routes stay unprefixed (/, /login, /logout,
/shares/..., /static/...) and only the outer mux adds the prefix. All
templates, redirects, and cookie paths updated accordingly. The root '/'
route reverts to the original unauthenticated welcome page (linking to
/web/), and /cal/, /card/, /files/ are unaffected.

Also gitignore the bin/ build output directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-08-19 07:29:32 +02:00
co-authored by Copilot
parent ab3c7f44d5
commit 4dba55c807
15 changed files with 58 additions and 52 deletions
+11 -10
View File
@@ -29,19 +29,20 @@ func NewServer(cfg *config.Config, st *store.Store, dbase *db.DB, logger *slog.L
return &Server{cfg: cfg, store: st, dbase: dbase, logger: logger}
}
// Handler returns the http.Handler serving the web UI, mounted at "/ui/"
// Handler returns the http.Handler serving the web UI, mounted at "/web/"
// by the caller (cmd/server). staticFS serves the compiled Tailwind CSS
// and any other static assets.
// and any other static assets. Since it's mounted with a path prefix,
// the caller must wrap this handler in http.StripPrefix("/web", ...).
func (s *Server) Handler(staticFS http.FileSystem) http.Handler {
mux := http.NewServeMux()
mux.Handle("/ui/static/", http.StripPrefix("/ui/static/", http.FileServer(staticFS)))
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(staticFS)))
mux.HandleFunc("/ui/login", s.handleLogin)
mux.HandleFunc("/ui/logout", s.handleLogout)
mux.HandleFunc("/ui/", s.requireLogin(s.handleDashboard))
mux.HandleFunc("/ui/shares/calendar", s.requireLogin(s.handleCalendarShare))
mux.HandleFunc("/ui/shares/addressbook", s.requireLogin(s.handleAddressBookShare))
mux.HandleFunc("/login", s.handleLogin)
mux.HandleFunc("/logout", s.handleLogout)
mux.HandleFunc("/", s.requireLogin(s.handleDashboard))
mux.HandleFunc("/shares/calendar", s.requireLogin(s.handleCalendarShare))
mux.HandleFunc("/shares/addressbook", s.requireLogin(s.handleAddressBookShare))
return mux
}
@@ -88,7 +89,7 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
s.setSessionCookie(w, token)
http.Redirect(w, r, "/ui/", http.StatusSeeOther)
http.Redirect(w, r, "/web/", http.StatusSeeOther)
}
func (s *Server) handleLogout(w http.ResponseWriter, r *http.Request) {
@@ -96,5 +97,5 @@ func (s *Server) handleLogout(w http.ResponseWriter, r *http.Request) {
_ = s.dbase.DeleteSession(cookie.Value)
}
s.clearSessionCookie(w)
http.Redirect(w, r, "/ui/login", http.StatusSeeOther)
http.Redirect(w, r, "/web/login", http.StatusSeeOther)
}