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

Move functionality into pluggable ASGI middleware stack #1489

Closed
6 tasks done
RobbeSneyders opened this issue Mar 17, 2022 · 0 comments
Closed
6 tasks done

Move functionality into pluggable ASGI middleware stack #1489

RobbeSneyders opened this issue Mar 17, 2022 · 0 comments
Assignees
Milestone

Comments

@RobbeSneyders
Copy link
Member

RobbeSneyders commented Mar 17, 2022

Currently, Connexion works by injecting its functionality in between the underlying framework app and the user view function, by wrapping the view function in decorators. (See our ARCHITECTURE.rst).

We propose to move most of this functionality to ASGI middleware, which is wrapped around the framework app. This allows this functionality to be framework agnostic, and actually work with any ASGI (or WSGI by using an adapter) compliant framework. This means that you can add the power of Connexion to existing apps of any of these frameworks, without Connexion having to maintain a framework-specific interface.

image
The only functionalities that cannot be moved to this framework agnostic middleware are the resolver to automatically map operations to python functions, and the automatic parameter unpacking which needs to remain a decorator since it needs to have access to the view function.

Originally posted in #1395 (comment)

This also makes the functionality pluggable so built-in features can easily be disabled and additional functionality can easily be added.

I've implemented a proof of concept that shows this middleware concept in #1477.

The goal is to:

  1. Make the middleware separately available for usage with any ASGI / WSGI app
from connexion import ConnexionMiddleware
from framework import App

app = App()
app = ConnexionMiddleware(app, __name__, specification_dir='openapi/')
app.add_api('my_api.yaml')
  1. Use it within the Connexion App so we can keep offering the current interface
from connexion import App

app = App(__name__, specification_dir='openapi/')
app.add_api('my_api.yaml')

Tasks

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

No branches or pull requests

1 participant