Laravel 5 跳过异常处理程序
Laravel 5 skip exception hander
我正在将支付网关集成到 Laravel 5 项目,支付网关站点有一个回调响应,
例如POSThttp://example.com/payments/response
但是支付失败返回419状态
我已经创建了一个路由来处理这个问题,例如
Route::post('payments/response', [
'as' => 'payments.response',
'uses' => 'PaymentController@response'
]);
BUT,总是落入app/Exceptions/Handler.php
public function render($request, Exception $exception)
{
if (in_array($request->route()->getName(), ['payments.response'])) {
// HOW TO SKIP THE EXCEPTION HANDLER ???
}
return parent::render($request, $exception);
}
我想继续回复到我的 PaymentController
,我该如何实现?
如果你正在调用 Call to undefined method app/Exceptions/Handler.php 你需要将控制器声明为 get not post.
我想通了。错误实际上是 TokenMismatchException
。因此,我的解决方案是
编辑app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
'payments/response', <------- ADD THIS
];
现在可以进入控制器
我正在将支付网关集成到 Laravel 5 项目,支付网关站点有一个回调响应,
例如POSThttp://example.com/payments/response
但是支付失败返回419状态
我已经创建了一个路由来处理这个问题,例如
Route::post('payments/response', [
'as' => 'payments.response',
'uses' => 'PaymentController@response'
]);
BUT,总是落入app/Exceptions/Handler.php
public function render($request, Exception $exception)
{
if (in_array($request->route()->getName(), ['payments.response'])) {
// HOW TO SKIP THE EXCEPTION HANDLER ???
}
return parent::render($request, $exception);
}
我想继续回复到我的 PaymentController
,我该如何实现?
如果你正在调用 Call to undefined method app/Exceptions/Handler.php 你需要将控制器声明为 get not post.
我想通了。错误实际上是 TokenMismatchException
。因此,我的解决方案是
编辑app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
'payments/response', <------- ADD THIS
];
现在可以进入控制器