router

package
v0.0.0-...-b8f35d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Overview

Package router provides a simple browser based router, which just works on the anchor element. It uses the anchor part to provide a virtual path and query parameters using the dom.Window Location.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Navigate(url string)

Navigate issues a navigation request to the window element.

Types

type Query

type Query struct {
	// contains filtered or unexported fields
}

Query represents a routing query and provides a simple access to query based parameters.

func (Query) Bool

func (p Query) Bool(key string) bool

func (Query) Float64

func (p Query) Float64(key string) float64

func (Query) Get

func (p Query) Get(key string) string

func (Query) GetAll

func (p Query) GetAll(key string) []string

GetAll returns all defined query parameters with that key.

func (Query) Int

func (p Query) Int(key string) int

func (Query) Path

func (p Query) Path() string

type Route

type Route struct {
	Path        string
	Constructor func(q Query)
}

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) AddRoute

func (r *Router) AddRoute(path string, f func(Query)) *Router

func (*Router) Invalidate

func (r *Router) Invalidate() error

func (*Router) Navigate

func (r *Router) Navigate(u *url.URL)

func (*Router) Release

func (r *Router) Release()

func (*Router) Reload

func (r *Router) Reload(force bool)

func (*Router) Routes

func (r *Router) Routes() []Route

func (*Router) SetUnhandledRouteAction

func (r *Router) SetUnhandledRouteAction(f func(Query)) *Router

func (*Router) Start

func (r *Router) Start()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL