}
@Put
@At("/:port/limit")
public Reply<?> limit(@Named("port") int port, Request request) {
ProxyServer proxy = proxyManager.get(port);
String upstreamKbps = request.param("upstreamKbps");
if (upstreamKbps != null) {
try {
proxy.setUpstreamKbps(Integer.parseInt(upstreamKbps));
} catch (NumberFormatException e) { }
}
String downstreamKbps = request.param("downstreamKbps");
if (downstreamKbps != null) {
try {
proxy.setDownstreamKbps(Integer.parseInt(downstreamKbps));
} catch (NumberFormatException e) { }
}
String latency = request.param("latency");
if (latency != null) {
try {
proxy.setLatency(Integer.parseInt(latency));
} catch (NumberFormatException e) { }
}
return Reply.saying().ok();
}