Skip to content

Commit

Permalink
fixed status code provider to only throw on 500 and 404
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Jun 20, 2018
1 parent 44c3faf commit 1bf03ff
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions masonite/providers/StatusCodeProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ def boot(self, StatusCode, Request):
if StatusCode == '200 OK':
return

if self.app.make('ViewClass').exists('errors/{}'.format(StatusCode.split(' ')[0])):
rendered_view = self.app.make('View')('errors/{}'.format(StatusCode.split(' ')[0])).rendered_template
else:
rendered_view = self.app.make('View')('/masonite/snippets/statuscode', {
'code': StatusCode
}).rendered_template
Headers = [
("Content-Length", str(len(rendered_view)))
]
self.app.bind('Response', rendered_view)

self.app.bind('Headers', Headers)
if StatusCode in ('500 Internal Server Error', '404 Not Found'):
if self.app.make('ViewClass').exists('errors/{}'.format(StatusCode.split(' ')[0])):
rendered_view = self.app.make('View')('errors/{}'.format(StatusCode.split(' ')[0])).rendered_template
else:
rendered_view = self.app.make('View')('/masonite/snippets/statuscode', {
'code': StatusCode
}).rendered_template
Headers = [

This comment has been minimized.

Copy link
@vaibhavmule

vaibhavmule Oct 10, 2018

Contributor

@josephmancuso is this line required?

This comment has been minimized.

Copy link
@vaibhavmule

vaibhavmule Oct 10, 2018

Contributor

I have removed it, more info on PR: #436

("Content-Length", str(len(rendered_view)))
]
self.app.bind('Response', rendered_view)

self.app.bind('Headers', Headers)

0 comments on commit 1bf03ff

Please sign in to comment.