Reroute to 404 if no route is to handle the URI

This commit is contained in:
斟酌 鵬兄 2014-10-22 10:38:50 +08:00
parent 56fe5a4b44
commit bbb604af66
2 changed files with 8 additions and 0 deletions

View File

@ -82,6 +82,7 @@ Router.prototype.route = function()
} }
} }
this.setRoute( "*", currentRoute );
this.routable = false; this.routable = false;
return false; return false;
}; };

View File

@ -18,6 +18,7 @@ var Framework = function( garden )
{ {
this.HTTP.response.statusCode = 404; this.HTTP.response.statusCode = 404;
this.result = "404 Not Found"; this.result = "404 Not Found";
this.plantResult();
}.bind( this ) }.bind( this )
} }
}; };
@ -70,6 +71,12 @@ Framework.prototype.parseResult = function()
continue; continue;
} }
} }
else if( method === false )
{
Dragonfly.Log( "No route is defined to handle this URI", Dragonfly.Spheres.THERMO );
this.router.routeObj.reroute( "404", true );
continue;
}
throw new FatalError( "Relay handler \"" + method + "\" is not defined" ); throw new FatalError( "Relay handler \"" + method + "\" is not defined" );
} }