API: Return a 404 error when no director rule is matched

This commit is contained in:
Andrew Short 2013-04-06 18:19:03 +11:00
parent 1dda9ae45f
commit 1fc780ce2b
2 changed files with 7 additions and 0 deletions

View File

@ -331,6 +331,9 @@ class Director implements TemplateGlobalProvider {
}
}
}
// No URL rules matched, so return a 404 error.
return new SS_HTTPResponse('No URL rule was matched', 404);
}
/**

View File

@ -281,6 +281,10 @@ class DirectorTest extends SapphireTest {
$this->assertEquals($headers, Director::extract_request_headers($request));
}
public function testUnmatchedRequestReturns404() {
$this->assertEquals(404, Director::test('no-route')->getStatusCode());
}
}
class DirectorTestRequest_Controller extends Controller implements TestOnly {