Skip to content

Injecting key, values into APIGatewayRestResolver object #5282

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

You must be logged in to vote

Hi @SeanCoaker, this is a very interesting question that customers always ask about dependency injection for various reasons: testing, code reuse, and others. Personally, I use dependency injection whenever I can, it makes a lot of things easier.

While our app.resolve(event, context) function doesn't support dependency injection directly on this, which makes sense because we focus on solving problems to resolve AWS events coming into Lambda, we do allow you to share data/classes/others through what we call contextual data. You can inject data before invoke app.resolve() and all routes will have access to that.

I created an example that can help you.

from aws_lambda_powertools import Logger

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@SeanCoaker
Comment options

@leandrodamascena
Comment options

@leandrodamascena
Comment options

Answer selected by SeanCoaker
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