diff --git a/htmx_route.go b/htmx_route.go index 8542a5c..dcd27e6 100644 --- a/htmx_route.go +++ b/htmx_route.go @@ -191,6 +191,7 @@ type HtmxRoute interface { ToUrlFromContext(c HtmxContext, language Language) string GetHtmx(language Language, queryParams ...HtmxPathParam) gomponents.Node SetActivePath(activePath *ActivePath) HtmxRoute + GetActivePath() *ActivePath GetPaths() LanguagePaths Add(server HtmxServer) Execute(c HtmxContext) @@ -353,6 +354,10 @@ type CommonHtmxRoute struct { createdLocation string } +func (h CommonHtmxRoute) GetActivePath() *ActivePath { + return h.ActivePath +} + func (h CommonHtmxRoute) GetPaths() LanguagePaths { return h.Paths } @@ -534,7 +539,9 @@ func (h *HtmxServerImpl) HandleStaticAndDefaultPath(defaultRoute HtmxRoute, defa return } if path == "/" { - defaultRoute.Execute(NewHtmxContext(r, w, defaultLanguage)) + context := NewHtmxContext(r, w, defaultLanguage) + context.SetActivePath(defaultRoute.GetActivePath()) + defaultRoute.Execute(context) return } http.Error(w, "Not found", http.StatusNotFound)