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:
+10
-10
@@ -51,7 +51,7 @@ func newTestServer(t *testing.T) *Server {
|
||||
func loginAs(t *testing.T, handler http.Handler, username, password string) *http.Cookie {
|
||||
t.Helper()
|
||||
form := url.Values{"username": {username}, "password": {password}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/ui/login", strings.NewReader(form.Encode()))
|
||||
req := httptest.NewRequest(http.MethodPost, "/login", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
@@ -80,7 +80,7 @@ func TestLoginSuccessAndFailure(t *testing.T) {
|
||||
|
||||
// Wrong password.
|
||||
form := url.Values{"username": {"alice"}, "password": {"wrong"}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/ui/login", strings.NewReader(form.Encode()))
|
||||
req := httptest.NewRequest(http.MethodPost, "/login", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
@@ -96,15 +96,15 @@ func TestDashboardRequiresLogin(t *testing.T) {
|
||||
s := newTestServer(t)
|
||||
handler := s.Handler(emptyStaticFS{})
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/ui/", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
|
||||
if rr.Code != http.StatusSeeOther {
|
||||
t.Fatalf("expected redirect to login, got %d", rr.Code)
|
||||
}
|
||||
if loc := rr.Result().Header.Get("Location"); loc != "/ui/login" {
|
||||
t.Fatalf("expected redirect to /ui/login, got %q", loc)
|
||||
if loc := rr.Result().Header.Get("Location"); loc != "/web/login" {
|
||||
t.Fatalf("expected redirect to /web/login, got %q", loc)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func TestDashboardShowsOwnResources(t *testing.T) {
|
||||
handler := s.Handler(emptyStaticFS{})
|
||||
cookie := loginAs(t, handler, "alice", "password")
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/ui/", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
req.AddCookie(cookie)
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
@@ -134,7 +134,7 @@ func TestShareUnshareCalendarFlow(t *testing.T) {
|
||||
|
||||
// Share alice's "work" calendar with bob, write access.
|
||||
form := url.Values{"resource": {"work"}, "shared_with": {"bob"}, "permission": {"write"}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/ui/shares/calendar", strings.NewReader(form.Encode()))
|
||||
req := httptest.NewRequest(http.MethodPost, "/shares/calendar", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.AddCookie(cookie)
|
||||
rr := httptest.NewRecorder()
|
||||
@@ -155,7 +155,7 @@ func TestShareUnshareCalendarFlow(t *testing.T) {
|
||||
}
|
||||
|
||||
// Unshare — htmx v2 sends DELETE params as a URL query string.
|
||||
req = httptest.NewRequest(http.MethodDelete, "/ui/shares/calendar?resource=work&shared_with=bob", nil)
|
||||
req = httptest.NewRequest(http.MethodDelete, "/shares/calendar?resource=work&shared_with=bob", nil)
|
||||
req.AddCookie(cookie)
|
||||
rr = httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
@@ -182,7 +182,7 @@ func TestCannotShareResourceNotOwned(t *testing.T) {
|
||||
|
||||
// alice doesn't own "personal" (that's bob's calendar).
|
||||
form := url.Values{"resource": {"personal"}, "shared_with": {"bob"}, "permission": {"write"}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/ui/shares/calendar", strings.NewReader(form.Encode()))
|
||||
req := httptest.NewRequest(http.MethodPost, "/shares/calendar", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.AddCookie(cookie)
|
||||
rr := httptest.NewRecorder()
|
||||
@@ -198,7 +198,7 @@ func TestLogoutClearsSession(t *testing.T) {
|
||||
handler := s.Handler(emptyStaticFS{})
|
||||
cookie := loginAs(t, handler, "alice", "password")
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/ui/logout", nil)
|
||||
req := httptest.NewRequest(http.MethodGet, "/logout", nil)
|
||||
req.AddCookie(cookie)
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
|
||||
Reference in New Issue
Block a user