lambda-proxy icon indicating copy to clipboard operation
lambda-proxy copied to clipboard

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

Open hdsiles opened this issue 5 years ago • 2 comments

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.

hdsiles avatar Jul 23 '20 19:07 hdsiles

@hdsiles thanks for opening the issue.

Sadly working with . is quite complex.

I think this is because in https://github.com/vincentsarago/lambda-proxy/blob/c39d0397bfcb324e24db52466193bb145c9d92a7/lambda_proxy/proxy.py#L25 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.

vincentsarago avatar Jul 23 '20 19:07 vincentsarago

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?

hdsiles avatar Jul 23 '20 20:07 hdsiles