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

pathArg variable does not work with a "." dot. #54

Open
hdsiles opened this issue Jul 23, 2020 · 2 comments
Open

pathArg variable does not work with a "." dot. #54

hdsiles opened this issue Jul 23, 2020 · 2 comments

Comments

@hdsiles
Copy link

hdsiles commented Jul 23, 2020

I am passing in users names in a first.last format and using a GET method to query information out of a table. When I pass in a username that does not have a period/dot in it it seems to work just fine.

I get back a result like the following:
"errorMessage": "No view function for: GET - /customers/00012345/users/first.last"

I am structuring the decorator like this:
@app.get('/customers/string:customer_id/users/string:user_name', cors=True)

Initially I did not specify a string for the arguments, but I had hoped that adding the 'string' in with it would tell it to accept exactly what it received.

@vincentsarago
Copy link
Owner

@hdsiles thanks for opening the issue.

Sadly working with . is quite complex.

I think this is because in

r"^<((?P<type>[a-zA-Z0-9_]+)(\((?P<pattern>.+)\))?\:)?(?P<name>[a-zA-Z0-9_]+)>$"
we only allow [a-zA-Z0-9_].

maybe you could try with regex

@app.get('/customers/string:customer_id/users/<regex(.+):username>', cors=True) but not sure it will work.

To be honest I'm slowly moving away from using lambda-proxy because it's now quite old and I'm mostly using FastAPI + Mangum (https://github.com/developmentseed/titiler#ø-aws-lambda) when I need to build an app.

@hdsiles
Copy link
Author

hdsiles commented Jul 23, 2020

I considered that section you posted as well as at least part of the culprit. I attempted a regex also, but I did not alter what was in the examples. Your regex solution does seem to get the job done though!

That said, should I consider using FastAPI if your intent is to stop maintaining this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants