Skip to content

Add strip preffix feature #10

@pkucmus

Description

@pkucmus

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions