Documentation ¶
Index ¶
Constants ¶
View Source
const ActiveRoute = "ACTIVE_ROUTE"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
type HandlerFunc func(...interface{}) vecty.ComponentOrHTML
type Router ¶
type Router struct { vecty.Core NotFound HandlerFunc // contains filtered or unexported fields }
Router is a component which simplifies registering of components and proxying them depending on the path. This uses pushstate for navigation.
func (*Router) BeforeRendering ¶
func (r *Router) BeforeRendering() func()
func (*Router) Handle ¶
func (r *Router) Handle(pattern string, h HandlerFunc)
Handle register the handler for the matched pattern. At the moment a map is used to store the pattern/handler so matching is done on a full string comparison, the pattern is used as key.
TODO: use trie for pattern matching.
func (*Router) Mount ¶
func (r *Router) Mount()
Mount registers event listener for onpopstate global event.
func (*Router) Render ¶
func (r *Router) Render() vecty.ComponentOrHTML
Render renders the active component register in the router. If there was any context supplied which calling pushState, it is passed to the handler.
Click to show internal directories.
Click to hide internal directories.