-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.go
47 lines (36 loc) · 1.34 KB
/
callback.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
47
package checkpoint
// Callbacks should be used only for custom metrics, logging and monitoring purpose.
type Callbacks struct {
BeforeRequest func(map[string]interface{}, map[string]interface{})
AfterRequest func(map[string]interface{}, map[string]interface{})
OnSuccess func(map[string]interface{}, map[string]interface{})
OnFailure func(map[string]interface{}, map[string]interface{})
}
func (c *Checkpoint) initCallbacks(callbacks *Callbacks) {
c.Callbacks = &Callbacks{
BeforeRequest: DefaultAfterRequest,
AfterRequest: DefaultAfterRequest,
OnSuccess: DefaultOnSuccess,
OnFailure: DefaultOnFailure,
}
if callbacks.BeforeRequest != nil {
c.Callbacks.BeforeRequest = callbacks.BeforeRequest
}
if callbacks.AfterRequest != nil {
c.Callbacks.AfterRequest = callbacks.AfterRequest
}
if callbacks.OnSuccess != nil {
c.Callbacks.OnSuccess = callbacks.OnSuccess
}
if callbacks.OnFailure != nil {
c.Callbacks.OnFailure = callbacks.OnFailure
}
}
func DefaultBeforeRequest(values map[string]interface{}, reqValues map[string]interface{}) {
}
func DefaultAfterRequest(values map[string]interface{}, reqValues map[string]interface{}) {
}
func DefaultOnSuccess(values map[string]interface{}, reqValues map[string]interface{}) {
}
func DefaultOnFailure(values map[string]interface{}, reqValues map[string]interface{}) {
}