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

Refactor routing into middleware-api-operation model #1533

Merged
merged 2 commits into from
May 13, 2022

Conversation

RobbeSneyders
Copy link
Member

This PR refactors the routing middleware into the middleware-api-operation model already used in the security middleware.

image

This model is often used in the API community and should be a good basis for any middleware that needs to act on an operation level.

@RobbeSneyders RobbeSneyders added this to the Connexion 3.0 milestone May 9, 2022
@coveralls
Copy link

Pull Request Test Coverage Report for Build 2297034892

  • 30 of 30 (100.0%) changed or added relevant lines in 4 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.0007%) to 94.336%

Files with Coverage Reduction New Missed Lines %
connexion/handlers.py 1 82.61%
Totals Coverage Status
Change from base Build 2270753938: -0.0007%
Covered Lines: 2698
Relevant Lines: 2860

💛 - Coveralls

Copy link
Member

@Ruwann Ruwann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Do you have a concrete reference to which also use this pattern? I'd be interested to see some other examples. I don't think I fully understand the change in this PR yet.

connexion/handlers.py Show resolved Hide resolved
@RobbeSneyders
Copy link
Member Author

RobbeSneyders commented May 12, 2022

Do you have a concrete reference to which also use this pattern? I'd be interested to see some other examples. I don't think I fully understand the change in this PR yet.

It's used by:

  • Flask: App - Blueprint - Route
  • Starlette: App - Router - Route
  • Django: Project - App - View
  • Connexion: App - API - Operation

In its simplest form, it's just a hierarchical set of routers. I think this is a lot easier to follow than the default_fn and call_next functions we had before. Especially if we repeat this pattern across our middlewares.

@Ruwann
Copy link
Member

Ruwann commented May 13, 2022

Alright, thanks for the clarification!

@RobbeSneyders RobbeSneyders merged commit 7d23a1e into main May 13, 2022
@RobbeSneyders RobbeSneyders deleted the feature/routing-refactor branch May 13, 2022 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants