router

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dynamic

type Dynamic struct {
	Params []string
	*Simple
}

Dynamic defines Dynamic router

type DynamicM

type DynamicM = map[string]map[string]*Dynamic

DynamicM type define map[string]*Simple

type Group

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

Group struct

func NewGroup

func NewGroup(prefix string) *Group

NewGroup return new group

func (*Group) Add

func (g *Group) Add(r ...*Router) *Group

Add routers

func (*Group) Prefix

func (g *Group) Prefix() string

Prefix return group's prefix

func (*Group) Routers

func (g *Group) Routers() []*Router

Routers return group's routers

type ParsedRouter

type ParsedRouter struct {
	// Simples routers
	Simples SimpleM
	// Dynamics routers K<Method> V< K<Pattern> V<Simple> >
	Dynamics DynamicM
}

ParsedRouter defines parsed router

func (*ParsedRouter) Handler

func (pr *ParsedRouter) Handler(ctx *context.Context) func(ctx *context.Context)

Handler found simple or dynamic handler

type Router

type Router struct {
	Simples  []*Simple
	Dynamics []*Dynamic
}

Router struct

func NewRouter

func NewRouter() *Router

NewRouter return new router

func (*Router) Delete

func (r *Router) Delete(pattern string, handler func(ctx *context.Context)) *Router

Delete Route Delete Method

func (*Router) FSResource

func (r *Router) FSResource(fs *embed.FS, pattern, file, contentType string) *Router

FSResource Route a resource

func (*Router) Get

func (r *Router) Get(pattern string, handler func(ctx *context.Context)) *Router

Get Route Get Method

func (*Router) Head

func (r *Router) Head(pattern string, handler func(ctx *context.Context)) *Router

Head Route Head Method

func (*Router) Options

func (r *Router) Options(pattern string, handler func(ctx *context.Context)) *Router

Options Route Options Method

func (*Router) Patch

func (r *Router) Patch(pattern string, handler func(ctx *context.Context)) *Router

Patch Route Patch Method

func (*Router) Post

func (r *Router) Post(pattern string, handler func(ctx *context.Context)) *Router

Post Route Post Method

func (*Router) Put

func (r *Router) Put(pattern string, handler func(ctx *context.Context)) *Router

Put Route Put Method

func (*Router) Request

func (r *Router) Request(pattern string, handler func(ctx *context.Context)) *Router

Request Route all Methods

func (*Router) Resource

func (r *Router) Resource(pattern, file, contentType string) *Router

Resource Route a resource

func (*Router) Route

func (r *Router) Route(method, pattern string, handler func(ctx *context.Context)) *Router

Route Route DIY Method

type Simple

type Simple struct {
	// Method route method
	Method string
	// Pattern route pattern
	Pattern string
	// Handler route handler
	Handler func(ctx *context.Context)
}

Simple struct

type SimpleM

type SimpleM = map[string]*Simple

SimpleM type define map[string]*Simple

Jump to

Keyboard shortcuts

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