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