grouter

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GRouter

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

func New

func New() *GRouter

func (*GRouter) Bind

func (g *GRouter) Bind() error

func (*GRouter) GetHandlersWithCache

func (g *GRouter) GetHandlersWithCache(r *Request) bool

func (*GRouter) Group

func (g *GRouter) Group(prefix string, groups ...func(group *RouterGroup)) *RouterGroup

type HandlerFunc

type HandlerFunc = func(r *Request)

Request handler function.

type Request

type Request struct {
	URL       string
	Payload   interface{}
	RouterMap map[string]string // Router parameters map, which might be nil if there're no router parameters.
}

func (*Request) GetRouterString

func (r *Request) GetRouterString(key string, def ...interface{}) string

GetRouterString retrieves and returns the router value as string with given key name <key>. It returns <def> if <key> does not exist.

func (*Request) GetRouterValue

func (r *Request) GetRouterValue(key string, def ...interface{}) interface{}

GetRouterValue retrieves and returns the router value with given key name <key>. It returns <def> if <key> does not exist.

func (*Request) GetRouterVar

func (r *Request) GetRouterVar(key string, def ...interface{}) *gvar.Var

GetRouterVar retrieves and returns the router value as gvar.Var with given key name <key>. It returns <def> if <key> does not exist.

type Router

type Router struct {
	Uri      string   // URI.
	RegRule  string   // Parsed regular expression for route matching.
	RegNames []string // Parsed router parameter names.
	Priority int      // Just for reference.
}

Router object.

type RouterGroup

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

RouterGroup is a group wrapping multiple routes and middleware.

func (*RouterGroup) Clone

func (g *RouterGroup) Clone() *RouterGroup

Clone returns a new router group which is a clone of current group.

func (*RouterGroup) GET

func (g *RouterGroup) GET(pattern string, object HandlerFunc) *RouterGroup

GET registers a http handler to given route pattern and http method: GET.

Jump to

Keyboard shortcuts

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