mirror of
https://github.com/kennethreitz/responder.git
synced 2026-06-05 23:00:17 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09fd0fb0ca | |||
| 72adb13c0f | |||
| ea0e382f82 | |||
| e70cba5143 | |||
| 8aec244c31 |
@@ -1,3 +1,6 @@
|
||||
# v0.0.9
|
||||
- Bugfix for async class-based views.
|
||||
|
||||
# v0.0.8
|
||||
- GraphiQL Support.
|
||||
- Improvement to route selection.
|
||||
|
||||
@@ -55,6 +55,7 @@ Features
|
||||
- Mutable response object, passed into each view. No need to return anything.
|
||||
- Background tasks, spawned off in a ``ThreadPoolExecutor``.
|
||||
- GraphQL (with *GraphiQL*) support!
|
||||
- OpenAPI schema generation.
|
||||
|
||||
Testimonials
|
||||
------------
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.0.8"
|
||||
__version__ = "0.0.10"
|
||||
|
||||
+8
-4
@@ -198,15 +198,19 @@ class API:
|
||||
|
||||
# Run on_request first.
|
||||
try:
|
||||
getattr(view, "on_request")(req, resp)
|
||||
r = getattr(view, "on_request")(req, resp)
|
||||
if hasattr(r, 'send'):
|
||||
await r
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
# Then on_get.
|
||||
method = req.method.lower()
|
||||
method = req.method
|
||||
|
||||
try:
|
||||
getattr(view, f"on_{method}")(req, resp)
|
||||
r = getattr(view, f"on_{method}")(req, resp)
|
||||
if hasattr(r, 'send'):
|
||||
await r
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
@@ -279,7 +283,7 @@ class API:
|
||||
return req.text
|
||||
|
||||
async def graphql_response(self, req, resp, schema):
|
||||
show_graphiql = req.method.lower() == "get" and req.accepts("text/html")
|
||||
show_graphiql = req.method == "get" and req.accepts("text/html")
|
||||
|
||||
if show_graphiql:
|
||||
resp.content = self.template_string(GRAPHIQL, endpoint=req.url.path)
|
||||
|
||||
@@ -348,3 +348,14 @@ def test_mount_wsgi_app(api, flask, session):
|
||||
|
||||
r = session.get("http://;/flask")
|
||||
assert r.ok
|
||||
|
||||
|
||||
def test_async_class_based_views(api, session):
|
||||
@api.route("/")
|
||||
class Resource:
|
||||
async def on_post(self, req, resp):
|
||||
resp.text = await req.text
|
||||
|
||||
data = "frame"
|
||||
r = session.post(api.url_for(Resource), data=data)
|
||||
assert r.text == data
|
||||
|
||||
Reference in New Issue
Block a user