Skip to content

Access route path parameters in middleware #4028

Answered by leandrodamascena
Sheemap asked this question in Q&A
Discussion options

You must be logged in to vote

If you are using Proxy then your path_parameters will be the full path and it is difficult to extract information, I agree.

If this is blocking you and is a critical requirement for your system, there is an alternative method to obtain this information more easily. However, it's worth noting that this approach is not considered best practice and may be subject to internal changes in the code with potential breaking changes.

We need to inject the route arguments in the context because we need to use it when invoking next_middleware or the next route, so, you can access the route path parameters by using _route_args variable.

_route_args = {'_route': <aws_lambda_powertools.event_handler.api…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Sheemap
Comment options

@leandrodamascena
Comment options

Answer selected by Sheemap
@Sheemap
Comment options

@leandrodamascena
Comment options

@Sheemap
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants