Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertMiddleware ¶
func ConvertMiddleware(ware Middleware) func(Handler) Handler
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
func NewChain ¶
func NewChain(constructors ...Constructor) Chain
func (Chain) Append ¶
func (c Chain) Append(constructors ...Constructor) Chain
func (Chain) ThenFunc ¶
func (c Chain) ThenFunc(fn HandlerFunc) Handler
type Constructor ¶
type Handler ¶
type Handler interface {
Handle(c *conn.Connection, pkg packet.IPacket)
}
func NotFoundHandler ¶
type HandlerFunc ¶
type HandlerFunc func(conn *conn.Connection, pkg packet.IPacket)
HandlerFunc 消息处理方法
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(c *conn.Connection, pkg packet.IPacket)
type Middleware ¶
type Middleware func(next HandlerFunc) HandlerFunc
func ToMiddleware ¶
func ToMiddleware(handler func(next Handler) Handler) Middleware
ToMiddleware converts the given handler to a Middleware.
type Route ¶
type Route struct { Matches any // 用于匹配的关键字段 Handler HandlerFunc // 处理方法 }
func WithMiddleware ¶
func WithMiddleware(middleware Middleware, rs ...Route) []Route
WithMiddleware adds given middleware to given route.
func WithMiddlewares ¶
func WithMiddlewares(ms []Middleware, rs ...Route) []Route
WithMiddlewares adds given middlewares to given routes.
Click to show internal directories.
Click to hide internal directories.