- default config support for limt_access_speed.
* fix bug when request.Body is nil.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user