forked from Necroforger/dgrouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
route.go
46 lines (36 loc) · 967 Bytes
/
route.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package dgrouter
// Route is a command route
type Route struct {
// Routes is a slice of subroutes
Routes []*Route
Name string
Aliases []string
Description string
Category string
// Matcher is a function that determines
// If this route will be matched
Matcher func(string) bool
// Handler is the Handler for this route
Handler HandlerFunc
// Default route for responding to bot mentions
Default *Route
// The parent for this route
Parent *Route
// Middleware to be applied when adding subroutes
Middleware []MiddlewareFunc
}
// Desc sets this routes description
func (r *Route) Desc(description string) *Route {
r.Description = description
return r
}
// Cat sets this route's category
func (r *Route) Cat(category string) *Route {
r.Category = category
return r
}
// Alias appends aliases to this route's alias list
func (r *Route) Alias(aliases ...string) *Route {
r.Aliases = append(r.Aliases, aliases...)
return r
}