Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default behaviour when the path parameters is not provided #20

Closed
simongarnier opened this issue Dec 6, 2017 · 4 comments
Closed

Default behaviour when the path parameters is not provided #20

simongarnier opened this issue Dec 6, 2017 · 4 comments
Assignees

Comments

@simongarnier
Copy link
Contributor

First of all, I want to thank you guys for this piece of code. I was looking for something to bind functions to HTTP methods when using AWS lambdas and was about to write it myself, but lambdarest came to the rescue.

However, I'm experiencing issues with how the binding behaves when you don't provide the path parameters. The way I see it, the behavior should be to match any path, not "/". This would allow matching on event with path parameters(eg: "/your/object/{id}"). Correct me if I'm wrong, but currently, it is impossible to match path with path parameters, because the path will be different on each event.

To support my use case, I wrote a decorator to hijack the event and set its path to "/" before calling the handler on it.

I already have an idea of how to implement this, I could submit a pull request if you think that this behavior is a good idea.

Just some thought, keep up the great work!

@sloev
Copy link
Owner

sloev commented Dec 7, 2017

Hi @simongarner. Thanks for engaging in the development.

As i understand it you are talking about two things:

  1. Default behaviour with no path:
    I agree that no path specified should match all

  2. The addition of path params:
    Is definetly a good idea but as the current handler lookup is using the path as key it would not work out of the box.
    A solution could be to make the lookup handler a deep dict with defaultdicts as wildcards and then split path on slashes to keys to make a nested lookup for the handler.
    Anyway from top of my head there is no simple solution for path vars atm but we could come up with it together 😊

Lets start with 1 and then colab on design of 2

  • johannes

@simongarnier
Copy link
Contributor Author

Hey @sloev,

I'm gonna hit you with a PR later today!

Just to be clear, you'll still be able to specify "/" if you want to match exactly "/", but if you pass an empty string in the path parameter, any path is going to match. I will keep the default value to "/", to avoid breaking anybody's project.

Simon

@sloev
Copy link
Owner

sloev commented Dec 7, 2017

Hi Simon thanks for the pr. Ive got a request for deleting a print statement and then we can merge. Lets open issue 2 in a seperate issue and close this one on merge

@sloev
Copy link
Owner

sloev commented Dec 8, 2017

merged

@sloev sloev closed this as completed Dec 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants