speed improvements
This commit is contained in:
parent
33f712ef9b
commit
62c1235f58
|
@ -98,6 +98,8 @@ class Sanic:
|
||||||
try:
|
try:
|
||||||
# Middleware process_request
|
# Middleware process_request
|
||||||
response = None
|
response = None
|
||||||
|
# The if improves speed. I don't know why
|
||||||
|
if self.request_middleware:
|
||||||
for middleware in self.request_middleware:
|
for middleware in self.request_middleware:
|
||||||
response = middleware(request)
|
response = middleware(request)
|
||||||
if isawaitable(response):
|
if isawaitable(response):
|
||||||
|
@ -118,6 +120,7 @@ class Sanic:
|
||||||
response = await response
|
response = await response
|
||||||
|
|
||||||
# Middleware process_response
|
# Middleware process_response
|
||||||
|
if self.response_middleware:
|
||||||
for middleware in self.response_middleware:
|
for middleware in self.response_middleware:
|
||||||
_response = middleware(request, response)
|
_response = middleware(request, response)
|
||||||
if isawaitable(_response):
|
if isawaitable(_response):
|
||||||
|
|
|
@ -14,8 +14,4 @@ app = Sanic("test")
|
||||||
async def test(request):
|
async def test(request):
|
||||||
return json({ "test": True })
|
return json({ "test": True })
|
||||||
|
|
||||||
@app.route("/file")
|
|
||||||
async def test(request):
|
|
||||||
return json({ "test": True, "files": request.files, "fields": request.form })
|
|
||||||
|
|
||||||
app.run(host="0.0.0.0", port=sys.argv[1])
|
app.run(host="0.0.0.0", port=sys.argv[1])
|
Loading…
Reference in New Issue
Block a user