-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmonitor_test.go
33 lines (31 loc) · 913 Bytes
/
monitor_test.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
package Figo
import (
"fmt"
"log"
"net/http"
"testing"
"time"
)
func TestMonitorMid(t *testing.T) {
m := NewMartini(1, 10, "")
simpleHandle := func() (int, string) {
log.Println("Enter Handler")
return 200, "hello"
}
m.Post("/test/post", MonitorMidCheck, simpleHandle)
m.Get("/test/get", MonitorMidCheck, simpleHandle)
m.Get("/test/get/withOutMonitor", simpleHandle)
go func() {
log.Fatal(http.ListenAndServe(":8080", nil))
}()
time.Sleep(time.Second * time.Duration(2))
cb := func(msgs ...string) {
str := fmt.Sprint(msgs)
client := GetSMTPClient("xujh945@qq.com", "xxxxxxxx", "smtp.qq.com:25")
client.Send("xujh945@qq.com", str, str)
client.Send("jianhui.xu@tendcloud.com", str, str)
}
MonitorCall("http://localhost:8080/test/post", "post", cb)
MonitorCall("http://localhost:8080/test/get", "get", cb)
MonitorCall("http://localhost:8080/test/get/withOutMonitor", "get", cb)
}