mirumee/smyth

Add strip preffix feature

Opened this issue · 0 comments

When using a config like this

[tool.smyth]
host = "0.0.0.0"
port = 8080

[tool.smyth.handlers.other_handler]
handler_path = "my_project.app.other_handler"
url_path = "/other/{path:path}"
timeout = 500

[tool.smyth.handlers.root_handler]
handler_path = "my_project.app.handler"
url_path = "/{path:path}"
timeout = 500

The other_handler handler receives the full path /other/{path:path} while I would like to have the option for it to be unaware of the /other part of the path.

So I suggest we add a strip_prefix option to the HandlerConfig which would let the event builder know to strip it from the rawPath and path:

smyth/src/smyth/event.py

Lines 10 to 18 in 725c856

"rawPath": request.url.path,
"body": (await request.body()).decode("utf-8"),
"isBase64Encoded": False,
"headers": dict(request.headers),
"queryStringParameters": dict(request.query_params),
"requestContext": {
"http": {
"method": request.method,
"path": request.url.path,