router

package
v0.0.0-...-3953a0d Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() interfaces.IRouter

Types

type Function

type Function struct {
	// route function name.
	Name string
	// route method, also is HTTP method,
	// 'MethodType' defined in method.go.
	Method MethodType
	// url of route.
	Url string
	// receiver of the Controller method.
	Recv reflect.Value
	// dto will be automatically instantiated according to the body
	// in json format.
	Dto reflect.Value
}

Function is used to register route

type MethodType

type MethodType int
const (
	Unknown MethodType = iota
	GET
	POST
	PUT
	DELETE
	PATCH
	OPTIONS
	HEAD
)

type Parser

type Parser struct {
	Funcs []*Function
	// contains filtered or unexported fields
}

func NewParser

func NewParser(controllers []interface{}) *Parser

NewParser Parse registered controllers to a parser, parser contains function slice, each function has the information needed by the router.

type Router

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

func (*Router) AddControllers

func (r *Router) AddControllers(controllers []interface{})

func (*Router) Handle

func (r *Router) Handle(c interfaces.IContext, i interfaces.IInjector)

Jump to

Keyboard shortcuts

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