-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.go
45 lines (36 loc) · 1.19 KB
/
plugins.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
package gozeep
// Plugin implemetns base plugin
type Plugin struct {
}
// Override to update the envelope or http headers when receiving a
// message.
func (p Plugin) ingress(envelope string, httpHeaders map[string]string, operation string) (string, map[string]string) {
return envelope, httpHeaders
}
func (p Plugin) egress(envelope string, httpHeaders map[string]string, operation string, bindingOptions string) (string, map[string]string) {
return envelope, httpHeaders
}
// HistoryPlugin implements base history plugin
type HistoryPlugin struct {
buffer []map[string]interface{}
}
// GetLastSent gets last sent message
func (h HistoryPlugin) GetLastSent() map[string]interface{} {
lastTx := h.buffer[len(h.buffer)-1]
if lastTx != nil && lastTx["sent"] != nil {
return lastTx["sent"].(map[string]interface{})
}
return nil
}
// GetLastReceived gets last received message
func (h HistoryPlugin) GetLastReceived() map[string]interface{} {
lastTx := h.buffer[len(h.buffer)-1]
if lastTx != nil && lastTx["received"] != nil {
return lastTx["received"].(map[string]interface{})
}
return nil
}
// Ingress method
// TODO: implement Ingress method
// Egress method
// TODO: implement Egress method