Skip to content

Commit

Permalink
Added server_args to AbstractApp (#1173)
Browse files Browse the repository at this point in the history
* Added server_args to AbstractApp

* Added server_args to AbstractApp

* Added server_args to AbstractApp

 * server_args are then passed to Flask aio_https constructors
 * Updated documentation to reflect the change

Co-authored-by: Taha Lukmanji <taha.lukmanji@ericsson.com>
  • Loading branch information
tahalukmanji and Taha Lukmanji authored Apr 25, 2020
1 parent 7e08135 commit aafc80a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions connexion/apps/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class AbstractApp(metaclass=abc.ABCMeta):
def __init__(self, import_name, api_cls, port=None, specification_dir='',
host=None, server=None, arguments=None, auth_all_paths=False, debug=None,
host=None, server=None, server_args=None, arguments=None, auth_all_paths=False, debug=None,
resolver=None, options=None, skip_error_handlers=False):
"""
:param import_name: the name of the application package
Expand All @@ -23,6 +23,8 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='',
:type specification_dir: pathlib.Path | str
:param server: which wsgi server to use
:type server: str | None
:param server_args: dictionary of arguments which are then passed to appropriate http server (Flask or aio_http)
:type server_args: dict | None
:param arguments: arguments to replace on the specification
:type arguments: dict | None
:param auth_all_paths: whether to authenticate not defined paths
Expand All @@ -45,8 +47,9 @@ def __init__(self, import_name, api_cls, port=None, specification_dir='',

self.options = ConnexionOptions(options)

self.app = self.create_app()
self.server = server
self.server_args = dict() if server_args is None else server_args
self.app = self.create_app()

# we get our application root path to avoid duplicating logic
self.root_path = self.get_root_path()
Expand Down
2 changes: 1 addition & 1 deletion connexion/apps/aiohttp_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, import_name, only_one_api=False, **kwargs):
self._api_added = False

def create_app(self):
return web.Application()
return web.Application(**self.server_args)

def get_root_path(self):
mod = sys.modules.get(self.import_name)
Expand Down
2 changes: 1 addition & 1 deletion connexion/apps/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, import_name, server='flask', **kwargs):
super(FlaskApp, self).__init__(import_name, FlaskApi, server=server, **kwargs)

def create_app(self):
app = flask.Flask(self.import_name)
app = flask.Flask(self.import_name, **self.server_args)
app.json_encoder = FlaskJSONEncoder
return app

Expand Down

0 comments on commit aafc80a

Please sign in to comment.