piotrmaslanka / falcon-ratelimit Goto Github PK
View Code? Open in Web Editor NEWRate limiter for Python Falcon framework
License: MIT License
Rate limiter for Python Falcon framework
License: MIT License
FYI, looks like falcon-ratelimit==1.1
is broken with the latest version of falcon, which is falcon==2.0.0
❯ gunicorn hello.app:api
[2019-05-24 14:10:19 -0300] [16138] [INFO] Starting gunicorn 19.9.0
[2019-05-24 14:10:19 -0300] [16138] [INFO] Listening at: http://127.0.0.1:8000 (16138)
[2019-05-24 14:10:19 -0300] [16138] [INFO] Using worker: sync
[2019-05-24 14:10:19 -0300] [16141] [INFO] Booting worker with pid: 16141
[2019-05-24 14:10:22 -0300] [16141] [ERROR] Error handling request /ping
Traceback (most recent call last):
File "/home/viniarck/repos/hello_api/.direnv/python-3.5.5/lib/python3.5/site-package
s/gunicorn/workers/sync.py", line 135, in handle
self.handle_request(listener, req, client, addr)
File "/home/viniarck/repos/hello_api/.direnv/python-3.5.5/lib/python3.5/site-package
s/gunicorn/workers/sync.py", line 176, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "falcon/api.py", line 274, in falcon.api.API.__call__
File "falcon/api.py", line 269, in falcon.api.API.__call__
File "/home/viniarck/repos/hello_api/.direnv/python-3.5.5/lib/python3.5/site-package
s/falcon/hooks.py", line 179, in do_before
action(req, resp, self, kwargs, *action_args, **action_kwargs)
TypeError: hook() takes 3 positional arguments but 4 were given
Code sample to reproduce:
import falcon
from falconratelimit import rate_limit
class PingResource(object):
@falcon.before(rate_limit(per_second=5, window_size=30))
def on_get(self, req, resp) -> None:
resp.media = {"test": "hello"}
api = falcon.API()
api.add_route("/ping", PingResource())
Testing the endpoint
❯ http GET :8000/ping
HTTP/1.1 500 Internal Server Error
Connection: close
Content-Length: 141
Content-Type: text/html
<html>
<head>
<title>Internal Server Error</title>
</head>
<body>
<h1><p>Internal Server Error</p></h1>
</body>
</html>
This same example works fine with falcon 1.4.1.
Thanks!
Hi,
How do I bypass when I don't have a 'forwarded_host' header in my request?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.