Repository navigation
Conversation
The example could not start. Three problems, each fatal on its own: - `LightAPI` is not exported; the class is `LightApi`, so the import raised ImportError before anything ran. - `Meta.rate_limit` used the key `request`; the middleware reads `requests`, so every call to /books returned 500 with KeyError. - `run(reload=True)` needs an import string, so uvicorn refused to start and only printed a warning. Every other example passes `debug=True`. Verified by running the example and calling the endpoint: the first three requests return 200 with a decreasing X-RateLimit-Remaining and the fourth returns 429.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small fix on top of your branch for iklobato#48. Only touches
examples/19_rate_limit.py.I tried to run the example and it did not start. Three problems, each one enough to break it:
from lightapi import ... LightAPI-> the class isLightApi, so the import fails right away:rate_limit = {"request": 3, ...}-> the middleware readsrequests, so every call to/booksreturns 500:app.run(..., reload=True)-> uvicorn needs an import string for reload, so it just prints a warning and exits:Changed it to
debug=True, which is what the other 18 examples use.I ran the example after the change and called the endpoint:
The middleware itself is unchanged. Your 4 tests still pass and so does the full suite (331 passed).