mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API: Return a 404 error when no director rule is matched
This commit is contained in:
parent
1dda9ae45f
commit
1fc780ce2b
@ -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));
|
$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 {
|
class DirectorTestRequest_Controller extends Controller implements TestOnly {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user