-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathexecutors.go
More file actions
39 lines (30 loc) · 789 Bytes
/
Copy pathexecutors.go
File metadata and controls
39 lines (30 loc) · 789 Bytes
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
package slacker
func executeCommand(ctx *CommandContext, handler CommandHandler, middlewares ...CommandMiddlewareHandler) {
if handler == nil {
return
}
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
handler(ctx)
}
func executeInteraction(ctx *InteractionContext, handler InteractionHandler, middlewares ...InteractionMiddlewareHandler) {
if handler == nil {
return
}
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
handler(ctx)
}
func executeJob(ctx *JobContext, handler JobHandler, middlewares ...JobMiddlewareHandler) func() {
if handler == nil {
return func() {}
}
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
return func() {
handler(ctx)
}
}