Skip to content

Commit

Permalink
updated response middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Nov 17, 2018
1 parent 0428881 commit 5ab823a
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions masonite/middleware/ResponseMiddleware.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
from masonite.request import Request
from masonite.response import Response

from masonite.app import App
from masonite.exceptions import ResponseError
from masonite.request import Request
from masonite.response import Response


class ResponseMiddleware:
Expand All @@ -13,15 +14,7 @@ def __init__(self, request: Request, app: App, response: Response):
self.response = response

def after(self):
if not self.request.redirect_url:
# Convert the data that is retrieved above to bytes
# so the wsgi server can handle it.
try:
self.response.to_bytes()
except TypeError:
raise ResponseError(
'An acceptable response type was not returned')
else:
if self.request.redirect_url:
self.response.redirect(self.request.redirect_url, status=302)
self.request.reset_redirections()

Expand Down

0 comments on commit 5ab823a

Please sign in to comment.