[relase] v0.1.18-unstable3
- restore network clean up
This commit is contained in:
parent
530ab120c0
commit
95e86f289e
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cosmos-server",
|
"name": "cosmos-server",
|
||||||
"version": "0.1.18-unstable2",
|
"version": "0.1.18-unstable3",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "test-server.js",
|
"main": "test-server.js",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
@ -63,7 +63,7 @@ func (w *SmartResponseWriterWrapper) Write(p []byte) (int, error) {
|
||||||
return 0, errors.New("Pending request cancelled due to SmartShield")
|
return 0, errors.New("Pending request cancelled due to SmartShield")
|
||||||
}
|
}
|
||||||
thro := shield.computeThrottle(w.policy, userConsumed)
|
thro := shield.computeThrottle(w.policy, userConsumed)
|
||||||
utils.Debug(fmt.Sprintf("Throttle: %d", thro))
|
|
||||||
w.ThrottleNext = 0
|
w.ThrottleNext = 0
|
||||||
if thro > 0 {
|
if thro > 0 {
|
||||||
time.Sleep(time.Duration(thro) * time.Millisecond)
|
time.Sleep(time.Duration(thro) * time.Millisecond)
|
||||||
|
|
|
@ -50,21 +50,21 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt
|
||||||
if route.UseHost {
|
if route.UseHost {
|
||||||
origin = origin.Host(route.Host)
|
origin = origin.Host(route.Host)
|
||||||
}
|
}
|
||||||
|
|
||||||
if route.UsePathPrefix {
|
if route.UsePathPrefix {
|
||||||
if route.PathPrefix != "" && route.PathPrefix[0] != '/' {
|
if route.PathPrefix != "" && route.PathPrefix[0] != '/' {
|
||||||
utils.Error("PathPrefix must start with a /", nil)
|
utils.Error("PathPrefix must start with a /", nil)
|
||||||
}
|
}
|
||||||
origin = origin.PathPrefix(route.PathPrefix)
|
origin = origin.PathPrefix(route.PathPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
if route.UsePathPrefix && route.StripPathPrefix {
|
if route.UsePathPrefix && route.StripPathPrefix {
|
||||||
if route.PathPrefix != "" && route.PathPrefix[0] != '/' {
|
if route.PathPrefix != "" && route.PathPrefix[0] != '/' {
|
||||||
utils.Error("PathPrefix must start with a /", nil)
|
utils.Error("PathPrefix must start with a /", nil)
|
||||||
}
|
}
|
||||||
destination = http.StripPrefix(route.PathPrefix, destination)
|
destination = http.StripPrefix(route.PathPrefix, destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
destination = SmartShieldMiddleware(route.SmartShield)(destination)
|
destination = SmartShieldMiddleware(route.SmartShield)(destination)
|
||||||
|
|
||||||
originCORS := route.CORSOrigin
|
originCORS := route.CORSOrigin
|
||||||
|
@ -102,6 +102,10 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt
|
||||||
)(destination)
|
)(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if route.MaxBandwith > 0 {
|
||||||
|
destination = utils.BandwithLimiterMiddleware(route.MaxBandwith)(destination)
|
||||||
|
}
|
||||||
|
|
||||||
origin.Handler(tokenMiddleware(route.AuthEnabled)(utils.CORSHeader(originCORS)((destination))))
|
origin.Handler(tokenMiddleware(route.AuthEnabled)(utils.CORSHeader(originCORS)((destination))))
|
||||||
|
|
||||||
utils.Log("Added route: [" + (string)(route.Mode) + "] " + route.Host + route.PathPrefix + " to " + route.Target + "")
|
utils.Log("Added route: [" + (string)(route.Mode) + "] " + route.Host + route.PathPrefix + " to " + route.Target + "")
|
||||||
|
|
|
@ -125,6 +125,7 @@ type ProxyRouteConfig struct {
|
||||||
ThrottlePerMinute int
|
ThrottlePerMinute int
|
||||||
CORSOrigin string
|
CORSOrigin string
|
||||||
StripPathPrefix bool
|
StripPathPrefix bool
|
||||||
|
MaxBandwith int64
|
||||||
AuthEnabled bool
|
AuthEnabled bool
|
||||||
Target string `validate:"required"`
|
Target string `validate:"required"`
|
||||||
SmartShield SmartShieldPolicy
|
SmartShield SmartShieldPolicy
|
||||||
|
|
Loading…
Reference in a new issue