Skip to content

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

Merged
heitorlessa merged 6 commits into
developfrom
feat/access_resolver_from_router
Nov 25, 2021
Merged

feat(apigateway): access parent api resolver from router#842
heitorlessa merged 6 commits into
developfrom
feat/access_resolver_from_router

Conversation

@to-mc

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

Copy link
Copy Markdown
Contributor

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

codecov-commenter commented Nov 22, 2021

Copy link
Copy Markdown

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.

@to-mc
to-mc requested a review from heitorlessa November 22, 2021 08:15
@heitorlessa

heitorlessa commented Nov 22, 2021 via email

Copy link
Copy Markdown
Contributor

@to-mc

to-mc commented Nov 24, 2021

Copy link
Copy Markdown
Contributor Author

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

heitorlessa commented Nov 24, 2021 via email

Copy link
Copy Markdown
Contributor

@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.

3 participants