-
-
Notifications
You must be signed in to change notification settings - Fork 761
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 empty connexion middleware #1492
Add empty connexion middleware #1492
Conversation
@@ -31,6 +32,38 @@ def json(self): | |||
return json.loads(self.text) | |||
|
|||
|
|||
def fixed_get_environ(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The WSGIMiddleware
and test client were unfortunately not compatible (see abersheeran/a2wsgi#21, pallets/werkzeug#2347). The issues are fixed, but I still had to patch the test client since the fixes are not released and I don't want to restrict the versions too much.
@@ -44,23 +44,23 @@ def test_errors(problem_app): | |||
|
|||
get_problem = app_client.get('/v1.0/problem') # type: flask.Response | |||
assert get_problem.content_type == 'application/problem+json' | |||
assert get_problem.status_code == 418 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a2wsgi.ASGIMiddleware
uses the builtin http
module underneath, which only supports status code 418 on Python 3.9+.
11d5b16
to
c696450
Compare
eae3cab
to
2b55ab5
Compare
f76f19d
to
b5832d1
Compare
c696450
to
34ed890
Compare
42ad775
to
f861b1c
Compare
f861b1c
to
e9b4dd7
Compare
e9b4dd7
to
977a691
Compare
@@ -23,16 +23,18 @@ def read_version(package): | |||
'clickclick>=1.2,<21', | |||
'jsonschema>=2.5.1,<5', | |||
'PyYAML>=5.1,<7', | |||
'requests>=2.19.1,<3', | |||
'requests>=2.27,<3', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to bump to 2.27?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of a sub-dependency which is shared by both requests
and starlette
. We'll be able to drop the requests
dependency once we move security into the middleware stack though, since we'll only need the AsyncSecurityHandlerFactory
then.
""" | ||
if middlewares is None: | ||
middlewares = self.default_middlewares | ||
self.app, self.apps = self._apply_middlewares(app, middlewares) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the apps
and middlewares
will have the opposite direction, given that we iterate on the reversed middlewares?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Probably not the most logical, so will return them reversed as well.
18d8f83
to
800b8ae
Compare
800b8ae
to
fe03909
Compare
Accidentally merged this one due to rebase hell @Ruwann. |
Part of #1489
This PR adds the empty ConnexionMiddleware and wraps it around the FlaskApp using the
a2wsgi.WSGIMiddleware
adapter.The ConnexionMiddleware and FlaskApp both implement the ASGI interface, and an ASGI server is the recommended way to run it.
The
a2wsgi.ASGIMiddleware
adapter is wrapped around the ASGI middleware to make it WSGI compliant so it can be used by the development server and test client.