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.
When registering API endpoints, the key was not used as the endpoint.
Instead, the
model.__tablename__
value was used within thecreate_handler
function and could not be changed by a user of LightAPI.The problem I see with that approach was that while the example shows that endpoints can be defined using a dictionary:
In this example, the endpoints
person
andcompany
are defined with LightAPI as of now. The given endpoint key is ignored further on.I added some logic that now uses the key, therefore the
Company
model is now using the endpointcustom-name
.Further on, the
/
at the beginning of the key string had to be omitted, otherwise the endpoint forPerson
would beip-address:8000//person/
.Let me know if you have any questions/suggestions for this commit.
Note: The current implementation requires a Python version >= 3.10 because of https://peps.python.org/pep-0604/. If you envision a larger support with other Python versions, let me know, I can change the code but this will result in less readability.