Skip to content

Commit

Permalink
Merge bc97b49 into 057a337
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Feb 12, 2019
2 parents 057a337 + bc97b49 commit 029d4f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion masonite/providers/StatusCodeProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def boot(self):
if request.is_status(200):
return

if request.get_status() not in (200, 301, 302):
if request.get_status() in (500, 405, 404):
if self.app.make('ViewClass').exists('errors/{}'.format(request.get_status())):
rendered_view = self.app.make('View')(
'errors/{}'.format(request.get_status()))
Expand Down
8 changes: 4 additions & 4 deletions masonite/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, app):
self.app = app
self.request = self.app.make('Request')

def json(self, payload):
def json(self, payload, status=200):
"""Gets the response ready for a JSON response.
Arguments:
Expand All @@ -32,7 +32,7 @@ def json(self, payload):
"""
self.app.bind('Response', json.dumps(payload))
self.make_headers(content_type="application/json; charset=utf-8")
self.request.status(200)
self.request.status(status)

return self.data()

Expand Down Expand Up @@ -89,9 +89,9 @@ def view(self, view, status=200):
self.request.status(status)

if isinstance(view, dict) or isinstance(view, list):
return self.json(view)
return self.json(view, status=self.request.get_status())
elif isinstance(view, Collection) or isinstance(view, Model):
view = self.json(view.serialize())
return self.json(view.serialize(), status=self.request.get_status())
elif isinstance(view, int):
view = str(view)
elif isinstance(view, View):
Expand Down

0 comments on commit 029d4f9

Please sign in to comment.