Documentation
¶
Overview ¶
Package router implements a simple history API router for Vecty (github.com/hexops/vecty). It can match exact patterns as well as named variables such as /users/{id}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNamedVar ¶
GetNamedVar returns the parsed named variables from a URL. If you did NewRoute("/blog/{id}", someComponent{}). Then you can do GetNamedVar(someComponent{}) and get a map like this: {"id": "id-var"}
func Link ¶
func Link(route, text string, opts LinkOptions) *vecty.HTML
Link implements a frontend history Anchor tag.
func NotFoundHandler ¶
NotFoundHandler renders if no routes are matched at all.
Types ¶
type EventCallback ¶
EventCallback defines a vecty onClick handler
type LinkOptions ¶
LinkOptions - use to pass extra options to the link element like an ID, or class attribute.
type NewRouteOpts ¶
type NewRouteOpts struct {
ExactMatch bool
}
NewRouteOpts let you specify route matching options, such as exact match.
type Route ¶
Route keeps track of the component and the route it's meant to be matched against. so when a the URL of the browser changes (pushState), we can check whether we need to render it or not.
func NewRoute ¶
func NewRoute(pattern string, c vecty.Component, opts NewRouteOpts) *Route
NewRoute takes a pattern and a component, if the pattern matches the current URL, then it returns the component, otherwise it returns an EmptyComponent.
func (*Route) Render ¶
func (r *Route) Render() vecty.ComponentOrHTML
Render renders the underlying component or EmptyComponent if route does not match