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

Add strip preffix feature #10

Open
pkucmus opened this issue May 11, 2024 · 0 comments
Open

Add strip preffix feature #10

pkucmus opened this issue May 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@pkucmus
Copy link
Contributor

pkucmus commented May 11, 2024

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,

@pkucmus pkucmus added the enhancement New feature or request label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant