From c82db192e10c0485bfd3fb512b89e1d5161d50e3 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Tue, 24 Jun 2025 22:13:05 +0100 Subject: [PATCH 1/2] Add redirect from root to /notes/ --- cmd/server/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/server/main.go b/cmd/server/main.go index b3cd124..6fddcba 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -21,6 +21,7 @@ func main() { router := http.NewServeMux() notesRouter := views.GetRoutes("/notes") + router.Handle("/", http.RedirectHandler("/notes/", http.StatusFound)) router.Handle("/notes/", http.StripPrefix("/notes", notesRouter)) router.Handle( conf.Conf.Static.Root, From 551dcf5905740cb3b9a93c884a2d5efc80079531 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Tue, 24 Jun 2025 22:14:32 +0100 Subject: [PATCH 2/2] Allow creating new note without trailing slash --- internal/notes/views/views.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/notes/views/views.go b/internal/notes/views/views.go index adcc693..71d849f 100644 --- a/internal/notes/views/views.go +++ b/internal/notes/views/views.go @@ -19,6 +19,7 @@ func GetRoutes(prefix string) *http.ServeMux { myurls = urls.URLs{ Prefix: prefix, URLs: map[string]urls.URL{ + "view_": {Path: "/{note}", Protocol: "GET", Handler: view}, "view": {Path: "/{note}/", Protocol: "GET", Handler: view}, "delete": {Path: "/{note}/delete/", Protocol: "GET", Handler: delete}, "edit": {Path: "/{note}/edit/", Protocol: "GET", Handler: edit},