MCPcopy Index your code
hub / github.com/Tong89/smartNode / wrapper

Function wrapper

backend/ratelimit.py:54–64  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

52 def decorator(fn):
53 @wraps(fn)
54 def wrapper(*args, **kwargs):
55 key = f"{fn.__name__}:{_identity_key()}"
56 allowed, remaining, retry = _limiter.check(key, limit, window)
57 if not allowed:
58 resp, status = error_response("RATE_LIMITED")
59 resp.headers["Retry-After"] = str(int(retry) + 1)
60 resp.headers["X-RateLimit-Limit"] = str(limit)
61 resp.headers["X-RateLimit-Remaining"] = "0"
62 return resp, status
63 result = fn(*args, **kwargs)
64 return result
65
66 return wrapper
67

Callers

nothing calls this directly

Calls 3

error_responseFunction · 0.90
_identity_keyFunction · 0.85
checkMethod · 0.45

Tested by

no test coverage detected