Get and set active paths for default route
This commit is contained in:
+8
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user