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

feat(apigateway): access parent api resolver from router #842

Merged
merged 6 commits into from Nov 25, 2021

Conversation

to-mc
Copy link
Contributor

@to-mc to-mc commented Nov 22, 2021

Issue #, if available: #834

Description of changes:

Enable access to parent api resolver class from child router classes. Example:

app.py

...
app = ApiGatewayResolver()
app.include_router(users.router, prefix="/users") # prefix 

def lambda_handler(event: Dict, context: LambdaContext):
    return app.resolve(event, context)

users.py

...

router = Router()

@router.get("/users/")
def get_users() -> Dict:
    router.api_resolver.custom_functionality()
    return {"message": "success"}

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 22, 2021
@to-mc to-mc changed the title Feat: access resolver from router feat: access api resolver from router Nov 22, 2021
@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2021

Codecov Report

Merging #842 (a95ca0b) into develop (fe2cf13) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #842   +/-   ##
========================================
  Coverage    99.90%   99.90%           
========================================
  Files          118      118           
  Lines         5108     5110    +2     
  Branches       280      280           
========================================
+ Hits          5103     5105    +2     
  Misses           2        2           
  Partials         3        3           
Impacted Files Coverage Δ
aws_lambda_powertools/event_handler/api_gateway.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe2cf13...a95ca0b. Read the comment docs.

@heitorlessa
Copy link
Contributor

heitorlessa commented Nov 22, 2021 via email

@to-mc
Copy link
Contributor Author

to-mc commented Nov 24, 2021

Should we add a note in the docs? E.g. subclassing ApiGatewayResolver etc

I think if we add documentation here it needs to be a more widely scoped section explaining how and why you might want to subclass ApiGatewayResolver, as opposed to just the particular detail this PR implements. I'd like to try and understand how common this is, and what some of the use cases are, before expanding on the docs there.

@heitorlessa
Copy link
Contributor

heitorlessa commented Nov 24, 2021 via email

@heitorlessa heitorlessa added the feature New feature or functionality label Nov 25, 2021
@heitorlessa heitorlessa changed the title feat: access api resolver from router feat(apigateway): access api resolver from router Nov 25, 2021
@heitorlessa heitorlessa changed the title feat(apigateway): access api resolver from router feat(apigateway): access parent api resolver from router Nov 25, 2021
@heitorlessa heitorlessa merged commit be6e722 into develop Nov 25, 2021
@heitorlessa heitorlessa deleted the feat/access_resolver_from_router branch November 25, 2021 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants