ginx

package
v0.0.0-...-3839eb7 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MetaKey = "coco.route.meta"

MetaKey meta key, could update if you need

Functions

func MetaHandler

func MetaHandler(meta Meta) gin.HandlerFunc

Types

type E

type E struct {
	Key string
	Val any
}

E element of M

func (*E) Bool

func (e *E) Bool() bool

func (*E) Float

func (e *E) Float() float64

func (*E) Int

func (e *E) Int() int

func (*E) String

func (e *E) String() string

type Meta

type Meta map[string]any

Meta route meta info

func M

func M(e ...E) Meta

func MetaFromCtx

func MetaFromCtx(ctx *gin.Context) Meta

func (Meta) Get

func (m Meta) Get(key string) (E, bool)

func (Meta) Has

func (m Meta) Has(key string) bool

type RouterGroup

type RouterGroup struct {
	FullPath string
	Meta     Meta
	// contains filtered or unexported fields
}

func NewRouterGroup

func NewRouterGroup(group *gin.RouterGroup) *RouterGroup

func (*RouterGroup) Any

func (r *RouterGroup) Any(path string, meta Meta, handlers ...gin.HandlerFunc) []*RouterHandler

func (*RouterGroup) Attach

func (r *RouterGroup) Attach(handlers ...gin.HandlerFunc)

Attach handlers to the root group directly

func (*RouterGroup) DELETE

func (r *RouterGroup) DELETE(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) GET

func (r *RouterGroup) GET(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) Group

func (r *RouterGroup) Group(path string, subMeta Meta, handlers ...gin.HandlerFunc) *RouterGroup

func (*RouterGroup) HEAD

func (r *RouterGroup) HEAD(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) Handle

func (r *RouterGroup) Handle(method string, path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) Match

func (r *RouterGroup) Match(methods []string, path string, meta Meta, handlers ...gin.HandlerFunc) []*RouterHandler

func (*RouterGroup) OPTIONS

func (r *RouterGroup) OPTIONS(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) POST

func (r *RouterGroup) POST(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) PUT

func (r *RouterGroup) PUT(path string, meta Meta, handlers ...gin.HandlerFunc) *RouterHandler

func (*RouterGroup) Use

func (r *RouterGroup) Use(handlers ...gin.HandlerFunc)

Use append the handlers to chain, group's chain will be inherited by subgroup and sub handlers

func (*RouterGroup) Walk

func (r *RouterGroup) Walk(walk func(info WalkRouteInfo) error) error

Walk walk group and handlers info, include subgroup

type RouterHandler

type RouterHandler struct {
	Method   string
	FullPath string
	Meta     Meta
	// contains filtered or unexported fields
}

type WalkRouteInfo

type WalkRouteInfo struct {
	IsGroup bool
	Group   *WalkRouteInfo

	Method   string
	FullPath string
	Meta     Meta
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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