mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #1729 from ajshort/no-rule-match-404
API: Return a 404 error when no director rule is matched
This commit is contained in:
commit
5c82efd61d
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user