File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,37 +51,24 @@ def handle_403(error):
5151 )
5252
5353
54- def _is_api_request ():
55- return request .path .startswith ('/api/' )
56-
57-
58- @mod_api .app_errorhandler (404 )
54+ @mod_api .errorhandler (404 )
5955def handle_404 (error ):
6056 """Not found."""
61- if _is_api_request ():
62- return make_error_response (
63- 'not_found' ,
64- getattr (error , 'description' , 'Resource not found.' ),
65- http_status = 404 ,
66- )
67- from run import not_found
68- return not_found (error )
57+ return make_error_response (
58+ 'not_found' ,
59+ getattr (error , 'description' , 'Resource not found.' ),
60+ http_status = 404 ,
61+ )
6962
7063
71- @mod_api .app_errorhandler (405 )
64+ @mod_api .errorhandler (405 )
7265def handle_405 (error ):
7366 """Handle method-not-allowed errors for API routes."""
74- if _is_api_request ():
75- resp = make_error_response (
76- 'method_not_allowed' ,
77- 'Method not allowed.' ,
78- http_status = 405 ,
79- )
80- if hasattr (error , 'valid_methods' ) and error .valid_methods :
81- resp .headers ['Allow' ] = ', ' .join (error .valid_methods )
82- return resp
83-
84- resp = make_response ("Method not allowed" , 405 )
67+ resp = make_error_response (
68+ 'method_not_allowed' ,
69+ 'Method not allowed.' ,
70+ http_status = 405 ,
71+ )
8572 if hasattr (error , 'valid_methods' ) and error .valid_methods :
8673 resp .headers ['Allow' ] = ', ' .join (error .valid_methods )
8774 return resp
You can’t perform that action at this time.
0 commit comments