router

package
v0.0.0-...-e31b469 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BodyTag    = "route_body"
	ContextTag = "route_ctx"
)

Variables

This section is empty.

Functions

func ListenDefault

func ListenDefault(r *LionRouter)

ListenDefault is to start listen by this route default instance.

Types

type BaseController

type BaseController struct {
	ResetReturn func(data *interface{}, ex *exception.Exception) (*[]byte, *exception.Exception)
	// contains filtered or unexported fields
}

func InitController

func InitController(route string) *BaseController

func (*BaseController) Delete

func (c *BaseController) Delete(f interface{}, paramsOrder ...string) *BaseController

func (*BaseController) FuncRun

func (c *BaseController) FuncRun(method string, params *Parameters, req *http.Request) (*[]byte, *exception.Exception)

func (*BaseController) Get

func (c *BaseController) Get(f interface{}, paramsOrder ...string) *BaseController

func (*BaseController) Post

func (c *BaseController) Post(f interface{}, paramsOrder ...string) *BaseController

func (*BaseController) Put

func (c *BaseController) Put(f interface{}, paramsOrder ...string) *BaseController

func (*BaseController) WebSocket

func (c *BaseController) WebSocket(w http.ResponseWriter, req *http.Request, params *map[string]string)

type Config

type Config struct {
	Address     string
	Port        string
	RoutePrefix string
}

type Context

type Context struct {
	Token   string
	Params  Parameters
	Request *http.Request
}

type HandleFunction

type HandleFunction struct {
	Func        reflect.Value
	ParamsNum   int
	ParamsOrder []string
	ParamsType  []reflect.Type
	HasBody     bool
}

type HandleFunctions

type HandleFunctions map[int]HandleFunction

type ILionController

type ILionController interface {
	FuncRun(method string, params *Parameters, req *http.Request) (*[]byte, *exception.Exception)
	Get(function interface{}, paramsorder ...string) *BaseController
	Post(function interface{}, paramsorder ...string) *BaseController
	Put(function interface{}, paramsorder ...string) *BaseController
	Delete(function interface{}, paramsorder ...string) *BaseController
	WebSocket(w http.ResponseWriter, req *http.Request, params *map[string]string)
}

type IParams

type IParams interface {
	AddParamData(name string, value string)
	RmoveParamData(name string)
}

type LionRouter

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

func InitRouter

func InitRouter(c *Config) *LionRouter

Default is get this route default instance.

func (*LionRouter) Register

func (r *LionRouter) Register(c *BaseController)

Register is to registe these URL into default route, then when linsen the default route.

func (*LionRouter) ServeHTTP

func (r *LionRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Parameters

type Parameters struct {
	ParamNum    int
	HasBody     bool
	ParamsOrder *[]string
	ParamsType  *[]reflect.Type
	ParamsFill  []bool
	FillOrder   []string
	ParamsData  *map[string]string
}

func (*Parameters) AddParamData

func (p *Parameters) AddParamData(name string, value string)

func (*Parameters) RmoveParamData

func (p *Parameters) RmoveParamData(name string)

type RouterItem

type RouterItem struct {
	Route      string
	Controller ILionController
}

Jump to

Keyboard shortcuts

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