webmcp
changeset 329:3db9b672ee73
404 handling of unroutable requests
author | jbe |
---|---|
date | Tue Mar 24 12:32:31 2015 +0100 (2015-03-24) |
parents | 04b0687130d8 |
children | 22275c74023a |
files | framework/env/request/handler.lua |
line diff
1.1 --- a/framework/env/request/handler.lua Tue Mar 24 01:58:17 2015 +0100 1.2 +++ b/framework/env/request/handler.lua Tue Mar 24 12:32:31 2015 +0100 1.3 @@ -34,7 +34,7 @@ 1.4 else 1.5 request._relative_baseurl = nil 1.6 end 1.7 - request._route = request.router() or {} 1.8 + request._route = request.router() 1.9 do 1.10 local post_id = http_request.post_params["_webmcp_id"] 1.11 if post_id then 1.12 @@ -45,11 +45,22 @@ 1.13 local success, error_info = xpcall( 1.14 function() 1.15 1.16 + if not request._route then 1.17 + request._route = {} 1.18 + if request.get_404_route() then 1.19 + request.set_status("404 Not Found") 1.20 + request.forward(request.get_404_route()) 1.21 + else 1.22 + error("Could not route request URL") 1.23 + end 1.24 + end 1.25 + 1.26 if request._route.static then 1.27 local f, errmsg = io.open(WEBMCP_BASE_PATH .. "static/" .. request._route.static, "r") 1.28 if not f then 1.29 request.set_status("404 Not Found") 1.30 if request.get_404_route() then 1.31 + request.set_status("404 Not Found") 1.32 request.forward(request.get_404_route()) 1.33 else 1.34 error('Could not open static file "' .. request._route.static .. '": ' .. errmsg)