# HG changeset patch # User jbe # Date 1427196751 -3600 # Node ID 3db9b672ee73549e9234ee3961de099f74e1d175 # Parent 04b0687130d879479390726551d1efd82031c012 404 handling of unroutable requests diff -r 04b0687130d8 -r 3db9b672ee73 framework/env/request/handler.lua --- a/framework/env/request/handler.lua Tue Mar 24 01:58:17 2015 +0100 +++ b/framework/env/request/handler.lua Tue Mar 24 12:32:31 2015 +0100 @@ -34,7 +34,7 @@ else request._relative_baseurl = nil end - request._route = request.router() or {} + request._route = request.router() do local post_id = http_request.post_params["_webmcp_id"] if post_id then @@ -45,11 +45,22 @@ local success, error_info = xpcall( function() + if not request._route then + request._route = {} + if request.get_404_route() then + request.set_status("404 Not Found") + request.forward(request.get_404_route()) + else + error("Could not route request URL") + end + end + if request._route.static then local f, errmsg = io.open(WEBMCP_BASE_PATH .. "static/" .. request._route.static, "r") if not f then request.set_status("404 Not Found") if request.get_404_route() then + request.set_status("404 Not Found") request.forward(request.get_404_route()) else error('Could not open static file "' .. request._route.static .. '": ' .. errmsg)