diff --git a/package.json b/package.json index a0f0d76..b7c90ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.1.6", + "version": "0.1.7", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/proxy/routerGen.go b/src/proxy/routerGen.go index d6de234..80c6d7d 100644 --- a/src/proxy/routerGen.go +++ b/src/proxy/routerGen.go @@ -72,7 +72,15 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt throttlePerMinute := route.ThrottlePerMinute if(throttlePerMinute == 0) { - throttlePerMinute = 60 + throttlePerMinute = 300 + } + + throtthleTime := 1*time.Minute + + // lets do something better later + if(throttlePerMinute == -1) { + throttlePerMinute = 99999999 + throtthleTime = 1*time.Second } originCORS := route.CORSOrigin @@ -93,7 +101,7 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt tokenMiddleware(route.AuthEnabled)( utils.CORSHeader(originCORS)( utils.MiddlewareTimeout(timeout * time.Millisecond)( - httprate.Limit(throttlePerMinute, 1*time.Minute, + httprate.Limit(throttlePerMinute, throtthleTime, httprate.WithKeyFuncs(httprate.KeyByIP), httprate.WithLimitHandler(func(w http.ResponseWriter, r *http.Request) { utils.Error("Too many requests. Throttling", nil)