webmcp
diff framework/env/request/handler.lua @ 352:2b5bdf9028fb
Code cleanup and performance improvements regarding 404 check; Deprecated encode.action_file_path{...} and encode.view_file_path{...}
author | jbe |
---|---|
date | Thu Mar 26 16:40:04 2015 +0100 (2015-03-26) |
parents | 8cf6d927d074 |
children | 545ec2e3eafa |
line diff
1.1 --- a/framework/env/request/handler.lua Thu Mar 26 16:38:30 2015 +0100 1.2 +++ b/framework/env/request/handler.lua Thu Mar 26 16:40:04 2015 +0100 1.3 @@ -8,16 +8,6 @@ 1.4 1.5 --]]-- 1.6 1.7 -local function file_exists(filename) 1.8 - local file = io.open(filename, "r") 1.9 - if file then 1.10 - io.close(file) 1.11 - return true 1.12 - else 1.13 - return false 1.14 - end 1.15 -end 1.16 - 1.17 function request.handler(http_request) 1.18 request._http_request = http_request 1.19 local path = http_request.path 1.20 @@ -105,12 +95,11 @@ 1.21 } 1.22 if 1.23 request.get_404_route() and 1.24 - not file_exists( 1.25 - encode.action_file_path{ 1.26 - module = request.get_module(), 1.27 - action = request.get_action() 1.28 - } 1.29 - ) 1.30 + not execute.action{ 1.31 + module = request.get_module(), 1.32 + action = request.get_action(), 1.33 + test_existence = true 1.34 + } 1.35 then 1.36 request.set_status("404 Not Found") 1.37 request.forward(request.get_404_route()) 1.38 @@ -171,12 +160,11 @@ 1.39 } 1.40 if 1.41 request.get_404_route() and 1.42 - not file_exists( 1.43 - encode.view_file_path{ 1.44 - module = request.get_module(), 1.45 - view = request.get_view() 1.46 - } 1.47 - ) 1.48 + not execute.view{ 1.49 + module = request.get_module(), 1.50 + view = request.get_view(), 1.51 + test_existence = true 1.52 + } 1.53 then 1.54 request.set_status("404 Not Found") 1.55 request.forward(request.get_404_route())