Merge pull request #8849 from kinglozzer/middleware-requesthandler-order

FIX: RequestHandler::__construct() should run after middlewares (fixes #8848)
This commit is contained in:
Robbie Averill 2019-03-19 14:43:22 +13:00 committed by GitHub
commit 94e5d0a642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -352,12 +352,11 @@ class Director implements TemplateGlobalProvider
break;
}
/** @var RequestHandler $controllerObj */
$controllerObj = Injector::inst()->create($arguments['Controller']);
// Handler for calling a controller
$handler = function (HTTPRequest $request) use ($controllerObj) {
// Handler for constructing and calling a controller
$handler = function (HTTPRequest $request) use ($arguments) {
try {
/** @var RequestHandler $controllerObj */
$controllerObj = Injector::inst()->create($arguments['Controller']);
return $controllerObj->handleRequest($request);
} catch (HTTPResponse_Exception $responseException) {
return $responseException->getResponse();