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
|
ToUrlFromContext(c HtmxContext, language Language) string
|
||||||
GetHtmx(language Language, queryParams ...HtmxPathParam) gomponents.Node
|
GetHtmx(language Language, queryParams ...HtmxPathParam) gomponents.Node
|
||||||
SetActivePath(activePath *ActivePath) HtmxRoute
|
SetActivePath(activePath *ActivePath) HtmxRoute
|
||||||
|
GetActivePath() *ActivePath
|
||||||
GetPaths() LanguagePaths
|
GetPaths() LanguagePaths
|
||||||
Add(server HtmxServer)
|
Add(server HtmxServer)
|
||||||
Execute(c HtmxContext)
|
Execute(c HtmxContext)
|
||||||
@@ -353,6 +354,10 @@ type CommonHtmxRoute struct {
|
|||||||
createdLocation string
|
createdLocation string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h CommonHtmxRoute) GetActivePath() *ActivePath {
|
||||||
|
return h.ActivePath
|
||||||
|
}
|
||||||
|
|
||||||
func (h CommonHtmxRoute) GetPaths() LanguagePaths {
|
func (h CommonHtmxRoute) GetPaths() LanguagePaths {
|
||||||
return h.Paths
|
return h.Paths
|
||||||
}
|
}
|
||||||
@@ -534,7 +539,9 @@ func (h *HtmxServerImpl) HandleStaticAndDefaultPath(defaultRoute HtmxRoute, defa
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if path == "/" {
|
if path == "/" {
|
||||||
defaultRoute.Execute(NewHtmxContext(r, w, defaultLanguage))
|
context := NewHtmxContext(r, w, defaultLanguage)
|
||||||
|
context.SetActivePath(defaultRoute.GetActivePath())
|
||||||
|
defaultRoute.Execute(context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
http.Error(w, "Not found", http.StatusNotFound)
|
http.Error(w, "Not found", http.StatusNotFound)
|
||||||
|
|||||||
Reference in New Issue
Block a user