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

Add middleware documentation #1706

Merged
merged 2 commits into from
Jun 7, 2023
Merged

Add middleware documentation #1706

merged 2 commits into from
Jun 7, 2023

Conversation

RobbeSneyders
Copy link
Member

Contributes towards #1531

This PR adds a documentation page on middleware.

@RobbeSneyders RobbeSneyders added this to the Connexion 3.0 milestone May 14, 2023
@RobbeSneyders RobbeSneyders requested a review from Ruwann May 14, 2023 21:10
@coveralls
Copy link

Coverage Status

Coverage: 94.043% (+0.002%) from 94.042% when pulling 5e4e6cb on feature/docs-middleware into 0c0c517 on main.

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.

Very nice documentation, don't have anything to add at this stage!

One question/comment on "first to last" order wrt middlewares, others are minor things

**SwaggerUIMiddleware**, Adds a Swagger UI to your application
**RoutingMiddleware**, "Routes incoming requests to the right operation defined in the
specification"
**SecurityMiddleware**, Checks incoming requests against the security defined in the spec
Copy link
Member

Choose a reason for hiding this comment

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

nit: inconsistency between "specification" in RoutingMiddleware and "spec" here

**RoutingMiddleware**, "Routes incoming requests to the right operation defined in the
specification"
**SecurityMiddleware**, Checks incoming requests against the security defined in the spec
**RequestValidationMiddleware**, validates the incoming requests against the spec
Copy link
Member

Choose a reason for hiding this comment

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

nit: validates --> Validates

The :code:`add_middleware` method takes a :code:`position` argument to define where in the
middleware stack it should be inserted, which should be an instance of the
:class:`~connexion.middleware.MiddlewarePosition` Enum. The positions below are ordered from
first to last. Note that responses hit the middlewares in reversed order.
Copy link
Member

Choose a reason for hiding this comment

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

What do you mean with "first to last"? 😅
I find it easier to talk about "outer" and "inner" when it comes to middleware, but might be personal?

If you need more flexibility, or want to modify or delete any of the default middlewares, you can
also pass in a customized middleware stack when instantiating your application.

For example, if you would like to remove the :class:`SecurityMiddleware` since you are handling
Copy link
Member

Choose a reason for hiding this comment

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

A remove_middleware() method or exclude argument could be useful indeed 😛

@RobbeSneyders RobbeSneyders merged commit fcd4e66 into main Jun 7, 2023
@RobbeSneyders RobbeSneyders deleted the feature/docs-middleware branch June 7, 2023 22:15
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.

3 participants