- default config support for limt_access_speed.

* fix bug when request.Body is nil.
This commit is contained in:
gazebo
2018-10-27 12:29:27 +08:00
parent ecb04fbe72
commit 6a5afbb07f
5 changed files with 41 additions and 5 deletions

View File

@@ -18,6 +18,9 @@ func TestLimitSpeed(t *testing.T) {
MaxAccessCount: 10,
TimeGapInSecond: 10,
},
}, &LimiterConfig{
MaxAccessCount: 1,
TimeGapInSecond: 2,
})
go func() {
@@ -36,5 +39,13 @@ func TestLimitSpeed(t *testing.T) {
count++
}
}()
go func() {
count := 0
for {
limiter.AccessAPI("otherAPI")
fmt.Printf("otherAPI, time:%s, count:%d\n", utils.GetCurTimeStr(), count)
count++
}
}()
time.Sleep(30 * time.Second)
}