forked from slack-io/slacker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executors.go
41 lines (31 loc) · 874 Bytes
/
executors.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
package slacker
import "github.com/slack-go/slack/socketmode"
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, request *socketmode.Request, middlewares ...InteractionMiddlewareHandler) {
if handler == nil {
return
}
for i := len(middlewares) - 1; i >= 0; i-- {
handler = middlewares[i](handler)
}
handler(ctx, request)
}
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)
}
}