hashrouter

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
var RT_PREFIX = "router:"
View Source
var RT_PREFIX_EXTERNAL = "external:"

Functions

This section is empty.

Types

type HashRouter

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

func NewRouter

func NewRouter() *HashRouter

Initialize a new router.

func (*HashRouter) AfterPageChange

func (r *HashRouter) AfterPageChange(f func(vars.Vars, *url.URL))

Set after page change function.

func (*HashRouter) Error

func (r *HashRouter) Error(code int, msg string) rterr.RouterError

Throw an error in the router with a message.

func (*HashRouter) Handle

func (r *HashRouter) Handle(hash string)

func (*HashRouter) Match

func (r *HashRouter) Match(hash string) (*routes.Route, bool)

func (*HashRouter) NameToTitle

func (r *HashRouter) NameToTitle(val bool)

func (*HashRouter) OnError

func (r *HashRouter) OnError(cb func(err error))

Decide what to do on errors.

func (*HashRouter) OnLoad

func (r *HashRouter) OnLoad(f func())

Set on load function.

func (*HashRouter) OnPageChange

func (r *HashRouter) OnPageChange(f func(vars.Vars, *url.URL))

Set on page change function.

func (*HashRouter) Redirect

func (r *HashRouter) Redirect(hash string)

func (*HashRouter) Register

func (r *HashRouter) Register(name, hash string, callable func(v vars.Vars, u *url.URL)) *routes.Route

Add a route to the router.

func (*HashRouter) Run

func (r *HashRouter) Run()

Start the router.

func (*HashRouter) SkipTrailingSlash

func (r *HashRouter) SkipTrailingSlash()

Skiptrailingslash to adhere to the router interface

func (*HashRouter) Throw

func (r *HashRouter) Throw(code int)

Throw an error in the router with predefined error code messages.

func (*HashRouter) Use

func (r *HashRouter) Use(middleware func(vars.Vars, *url.URL, *routes.Route, rterr.ErrorThrower) bool)

Add a middleware to the router.

Jump to

Keyboard shortcuts

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