Use workzeug for route parsing#30
Use workzeug for route parsing#30sloev merged 10 commits intosloev:mastersloev/python-lambdarest:masterfrom svdgraaf:feature/use-workzeug-for-route-parsingCopy head branch name to clipboard
Conversation
lambdarest/__init__.py
Outdated
| except KeyError: | ||
| logging.warning(logging_message.format( | ||
| status_code=405, message="Not supported")) | ||
| error_tuple = ("Not supported", 405) |
There was a problem hiding this comment.
What raises the KeyError and tells us that the HTTP method is unsupported?
There was a problem hiding this comment.
The KeyError was from before, removed it, not needed anymore.
lambdarest/__init__.py
Outdated
| logging_message = "[%s][{status_code}]: {message}" % method_name | ||
| try: | ||
| func = http_methods.get(path, http_methods.get("*", {}))[method_name] | ||
| mapping = url_maps.bind('example.com', '') |
There was a problem hiding this comment.
what does example.com have to do here?
There was a problem hiding this comment.
I figured we needed an server_name to bind it, but it's actually not needed at all, removed it.
lambdarest/__init__.py
Outdated
|
|
||
| # register http handler function | ||
| http_methods.setdefault(path.lower(), {})[method_name.lower()] = inner | ||
| # url_maps.setdefault(path.lower(), {})[method_name.lower()] = inner |
lambdarest/__init__.py
Outdated
| http_methods.setdefault(path.lower(), {})[method_name.lower()] = inner | ||
| # url_maps.setdefault(path.lower(), {})[method_name.lower()] = inner | ||
| rule = Rule(path, endpoint=inner, methods=[method_name.lower()]) | ||
| print(rule) |
|
When tests are green we can merge |
|
@sloev ok, working on it |
|
@sloev I fixed all the tests, but the py33 one is stuck, it seems to break on installing a dependency, but I'm not sure. |
|
I can fix the last one. Its because pylint no longer supports py3.3 |
|
good job @svdgraaf :-) |
* pep8 cleanup * Added werkzeug dependency * Use the werkzeug Map() object to do the mapping for us * Added description for using the path parameters * bind to an empty server name * Make readme have unique urls, all tests are run in the same context * Add exception for catch-all rule so * can be used as path * fixed absolute url redirect * fix pylint for py3.3 * bump version, write history
|
Thanks @sloev! Combining this with the Serverless framework makes it a lot easier to write a bit bigger api 😄 Stuff like this is awesome: |
|
hahaha Truly Awesome!!! Yeah i really like the lambda_handler "singleton" and that it's just a function. Python FTW. Please come back if you find bugs or have new features, nice collaborating wit you! |
TL/DR: This PR makes paths like
/foo/bar/<int:id>/work.I needed path parameter support for my api, I noticed that Workzeug (from Flask) solved that issue already, and here we are.