v0.1.7 Temp fix for disabling throttle
This commit is contained in:
parent
7ed6047f4e
commit
92fe080833
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -72,7 +72,15 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt
|
||||||
throttlePerMinute := route.ThrottlePerMinute
|
throttlePerMinute := route.ThrottlePerMinute
|
||||||
|
|
||||||
if(throttlePerMinute == 0) {
|
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
|
originCORS := route.CORSOrigin
|
||||||
|
@ -93,7 +101,7 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt
|
||||||
tokenMiddleware(route.AuthEnabled)(
|
tokenMiddleware(route.AuthEnabled)(
|
||||||
utils.CORSHeader(originCORS)(
|
utils.CORSHeader(originCORS)(
|
||||||
utils.MiddlewareTimeout(timeout * time.Millisecond)(
|
utils.MiddlewareTimeout(timeout * time.Millisecond)(
|
||||||
httprate.Limit(throttlePerMinute, 1*time.Minute,
|
httprate.Limit(throttlePerMinute, throtthleTime,
|
||||||
httprate.WithKeyFuncs(httprate.KeyByIP),
|
httprate.WithKeyFuncs(httprate.KeyByIP),
|
||||||
httprate.WithLimitHandler(func(w http.ResponseWriter, r *http.Request) {
|
httprate.WithLimitHandler(func(w http.ResponseWriter, r *http.Request) {
|
||||||
utils.Error("Too many requests. Throttling", nil)
|
utils.Error("Too many requests. Throttling", nil)
|
||||||
|
|
Loading…
Reference in a new issue