summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-09-26 12:56:12 -0400
committerCorey Hulen <corey@hulen.com>2016-09-26 09:56:12 -0700
commit7fcc004beb9f6ef022f755e8e2f2a958c976c637 (patch)
treedc8a34d4bc57878361307d92c8032b6bd776d40a /api
parentdff985a92402319c16ad599e635b367fb123d60b (diff)
downloadchat-7fcc004beb9f6ef022f755e8e2f2a958c976c637.tar.gz
chat-7fcc004beb9f6ef022f755e8e2f2a958c976c637.tar.bz2
chat-7fcc004beb9f6ef022f755e8e2f2a958c976c637.zip
Modifications to rate limiting settings. (#4091)
Diffstat (limited to 'api')
-rw-r--r--api/apitestlib.go4
-rw-r--r--api/server.go11
2 files changed, 8 insertions, 7 deletions
diff --git a/api/apitestlib.go b/api/apitestlib.go
index c043fe2ae..9345d3fc4 100644
--- a/api/apitestlib.go
+++ b/api/apitestlib.go
@@ -33,7 +33,7 @@ func SetupEnterprise() *TestHelper {
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
- utils.Cfg.RateLimitSettings.EnableRateLimiter = false
+ *utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
utils.License.Features.SetDefaults()
NewServer()
@@ -55,7 +55,7 @@ func Setup() *TestHelper {
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
- utils.Cfg.RateLimitSettings.EnableRateLimiter = false
+ *utils.Cfg.RateLimitSettings.Enable = false
utils.DisableDebugLogForTest()
NewServer()
StartServer()
diff --git a/api/server.go b/api/server.go
index b16ad6e8e..979c8f5ef 100644
--- a/api/server.go
+++ b/api/server.go
@@ -4,6 +4,10 @@
package api
import (
+ "net/http"
+ "strings"
+ "time"
+
l4g "github.com/alecthomas/log4go"
"github.com/braintree/manners"
"github.com/gorilla/handlers"
@@ -12,9 +16,6 @@ import (
"github.com/mattermost/platform/utils"
"gopkg.in/throttled/throttled.v2"
"gopkg.in/throttled/throttled.v2/store/memstore"
- "net/http"
- "strings"
- "time"
)
type Server struct {
@@ -70,7 +71,7 @@ func StartServer() {
var handler http.Handler = &CorsWrapper{Srv.Router}
- if utils.Cfg.RateLimitSettings.EnableRateLimiter {
+ if *utils.Cfg.RateLimitSettings.Enable {
l4g.Info(utils.T("api.server.start_server.rate.info"))
store, err := memstore.New(utils.Cfg.RateLimitSettings.MemoryStoreSize)
@@ -81,7 +82,7 @@ func StartServer() {
quota := throttled.RateQuota{
MaxRate: throttled.PerSec(utils.Cfg.RateLimitSettings.PerSec),
- MaxBurst: 100,
+ MaxBurst: *utils.Cfg.RateLimitSettings.MaxBurst,
}
rateLimiter, err := throttled.NewGCRARateLimiter(store, quota)