router

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

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

Router is the main router struct.

func NewRouter

func NewRouter() *Router

Initialize a new router.

func (*Router) Error

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

Throw an error in the router with a message.

func (*Router) GetRoute

func (r *Router) GetRoute(name string) *routes.Route

Get a route by name. If it does not directly exist, it will search in the subroutes.

func (*Router) HandlePath

func (r *Router) HandlePath(path string)

Handle a path.

func (*Router) Match

func (r *Router) Match(path string) (*routes.Route, vars.Vars, bool)

Match a raw path.

func (*Router) OnError

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

Decide what to do on errors.

func (*Router) Redirect

func (r *Router) Redirect(path string)

Handle a path in the form of a redirect. NYI.

func (*Router) RedirectNamed

func (r *Router) RedirectNamed(name string, varMap vars.Vars)

Redirect to a route by name.

func (*Router) Register

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

Register a new route. If the route name already exists, it will panic.

func (*Router) SkipTrailingSlash

func (r *Router) SkipTrailingSlash()

SkipTrailingSlash will skip the trailing slash in the path.

func (*Router) String

func (r *Router) String() string

Display nicely formatted URLs

func (*Router) Throw

func (r *Router) Throw(code int)

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

func (*Router) Use

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

Add a middleware to the router.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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