mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 23:00:17 +00:00
mount flaks apps
This commit is contained in:
@@ -6,7 +6,6 @@ name = "pypi"
|
||||
[packages]
|
||||
responder = {editable = true, path = "."}
|
||||
|
||||
|
||||
[dev-packages]
|
||||
pytest = "*"
|
||||
"flake8" = "*"
|
||||
|
||||
Generated
+14
@@ -37,6 +37,20 @@
|
||||
],
|
||||
"version": "==1.0.0b3"
|
||||
},
|
||||
"asgiref": {
|
||||
"hashes": [
|
||||
"sha256:9b05dcd41a6a89ca8c6e7f7e4089c3f3e76b5af60aebb81ae6d455ad81989c97",
|
||||
"sha256:b21dc4c43d7aba5a844f4c48b8f49d56277bc34937fd9f9cb93ec97fde7e3082"
|
||||
],
|
||||
"version": "==2.3.2"
|
||||
},
|
||||
"async-timeout": {
|
||||
"hashes": [
|
||||
"sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
|
||||
"sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3"
|
||||
],
|
||||
"version": "==3.0.1"
|
||||
},
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:339dc09518b07e2fa7eda5450740925974815557727d6bd35d319c1524a04a4c",
|
||||
|
||||
+10
-5
@@ -14,6 +14,7 @@ from starlette.testclient import TestClient
|
||||
from apispec import APISpec
|
||||
from apispec.ext.marshmallow import MarshmallowPlugin
|
||||
from apispec import yaml_utils
|
||||
from asgiref.wsgi import WsgiToAsgi
|
||||
|
||||
from . import models
|
||||
from . import status_codes
|
||||
@@ -104,7 +105,11 @@ class API:
|
||||
if path.startswith(path_prefix):
|
||||
scope["path"] = path[len(path_prefix) :]
|
||||
scope["root_path"] = root_path + path_prefix
|
||||
return app(scope)
|
||||
try:
|
||||
return app(scope)
|
||||
except TypeError:
|
||||
app = WsgiToAsgi(app)
|
||||
return app(scope)
|
||||
|
||||
# Call the main dispatcher.
|
||||
async def asgi(receive, send):
|
||||
@@ -299,13 +304,13 @@ class API:
|
||||
|
||||
return decorator
|
||||
|
||||
def mount(self, route, asgi_app):
|
||||
"""Mounts an ASGI application at a given route.
|
||||
def mount(self, route, app):
|
||||
"""Mounts an WSGI / ASGI application at a given route.
|
||||
|
||||
:param route: String representation of the route to be used (shouldn't be parameterized).
|
||||
:param asgi_app: The other ASGI app.
|
||||
:param app: The other WSGI / ASGI app.
|
||||
"""
|
||||
self.apps.update({route: asgi_app})
|
||||
self.apps.update({route: app})
|
||||
|
||||
def session(self, base_url="http://;"):
|
||||
"""Testing HTTP client. Returns a Requests session object, able to send HTTP requests to the Responder application.
|
||||
|
||||
@@ -37,6 +37,7 @@ required = [
|
||||
"chardet",
|
||||
"apispec>=1.0.0b1",
|
||||
"marshmallow",
|
||||
"asgiref",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -323,7 +323,6 @@ def test_schema_generation():
|
||||
assert dump["openapi"] == "3.0"
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_mount_wsgi_app(api, flask, session):
|
||||
@api.route("/")
|
||||
def hello(req, resp):
|
||||
|
||||
Reference in New Issue
Block a user