Documentation ¶
Index ¶
- Constants
- Variables
- type Args
- type Context
- type HandlerFunc
- type MiddlewareFunc
- type Route
- func (r *Route) AddRoute(route *Route) error
- func (r *Route) Cat(cat string) *Route
- func (r *Route) Desc(desc string) *Route
- func (r *Route) Find(name string) *Route
- func (r *Route) FindAll(args ...string) (*Route, int)
- func (r *Route) HandleFunc(name string, handler HandlerFunc) *Route
- func (r *Route) Listen(ses *discordgo.Session, evt interface{}, prefix string) error
- func (r *Route) Use(fn ...MiddlewareFunc) *Route
- func (r *Route) Usg(usg string) *Route
Constants ¶
View Source
const Sep = ' '
Sep is the separator for the arguments
Variables ¶
View Source
var ( ErrAlreadyExist = errors.New("Router already exist") ErrNotFound = errors.New("Router not found") )
Error variables
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Route *Route Routes []*Route Evt interface{} Ses *discordgo.Session Args Args }
Context is the object for the router context
func NewContext ¶
func NewContext(route *Route, routes []*Route, evt interface{}, ses *discordgo.Session, args Args) *Context
NewContext create and return new router context object
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc is the handler function for thenrouter
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc is the middleware function for the router
type Route ¶
type Route struct { Name string Description string Category string // Routes is list of registered routers Routes []*Route Handler HandlerFunc // Middleware is the list of registered middlewares Middleware []MiddlewareFunc // Usage is the help details Usage string }
Route is the router object
func (*Route) HandleFunc ¶
func (r *Route) HandleFunc(name string, handler HandlerFunc) *Route
HandleFunc register the new handler for the given route
func (*Route) Use ¶
func (r *Route) Use(fn ...MiddlewareFunc) *Route
Use register the middleware to the router
Click to show internal directories.
Click to hide internal directories.