-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add request object back to the error handler. #95
Comments
@tuupola FYI I did a workaround on v3.3.1 to be able to throw a Slim HTTP code. use Slim\Exception\HttpUnauthorizedException;
// 1st middleware to configure basic authentication
$app->add(new HttpBasicAuthentication([
"users" => [
"root" => "secret",
],
"error" => function ($response) {
return $response->withStatus(401);
}
]));
// 2nd middleware to throw 401 with correct slim exception
$app->add(function (Request $request, RequestHandler $handler) {
$response = $handler->handle($request);
$statusCode = $response->getStatusCode();
if ($statusCode == 401) {
throw new HttpUnauthorizedException($request);
}
return $response;
}); any other way to get the request object? |
Changing the
We can PR this, but that would be breaking for older installations. As intermit step, adding a option to throw an Exception instead would also give the desired effect. |
Yeah cannot break BC. A kludgish workaround would be to include the request object in the second parameter which is an array. 4.x version is planned but since I recently started freelancing paid work comes first atm. |
Add request object back as parameter to the error handler.
See tuupola/branca-middleware#13 for reference.
The text was updated successfully, but these errors were encountered: