This repository has been archived by the owner on Nov 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Phossa Project | ||
* | ||
* PHP version 5.4 | ||
* | ||
* @category Library | ||
* @package Phossa2\Middleware | ||
* @copyright Copyright (c) 2016 phossa.com | ||
* @license http://mit-license.org/ MIT License | ||
* @link http://www.phossa.com/ | ||
*/ | ||
/*# declare(strict_types=1); */ | ||
|
||
namespace Phossa2\Middleware\Middleware; | ||
|
||
use Psr\Http\Message\RequestInterface; | ||
use Phossa2\Shared\Base\ObjectAbstract; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Franzl\Middleware\Whoops\WhoopsRunner; | ||
use Phossa2\Middleware\Interfaces\DelegateInterface; | ||
use Phossa2\Middleware\Interfaces\MiddlewareInterface; | ||
|
||
/** | ||
* WhoopsMiddleware | ||
* | ||
* Using "franzl/whoops-middleware" for Whoops | ||
* | ||
* @package Phossa2\Middleware | ||
* @author Hong Zhang <phossa@126.com> | ||
* @version 2.1.0 | ||
* @since 2.1.0 added | ||
*/ | ||
class WhoopsMiddleware extends ObjectAbstract implements MiddlewareInterface | ||
{ | ||
/** | ||
* Should be the very first middleware in the queue | ||
* | ||
* {@inheritDoc} | ||
*/ | ||
public function process( | ||
RequestInterface $request, | ||
ResponseInterface $response, | ||
DelegateInterface $next = null | ||
) { | ||
try { | ||
return $next->next($request, $response); | ||
} catch (\Exception $e) { | ||
return WhoopsRunner::handle($e, $request); | ||
} | ||
} | ||
} |