-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Creating MiddlewareManager to handle the compilation of middleware into a callable RequestHandler chain. - Creating RouteResolverMiddleware responsible for resolving middleware and attaching route to ServerRequest instance as an attribute. - Allow optional MiddlewareManager instance in contructor.
- Loading branch information
Brent Scheffler
committed
Nov 25, 2019
1 parent
e61a476
commit 010855d
Showing
12 changed files
with
522 additions
and
365 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Limber; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Throwable; | ||
|
||
class ExceptionManager | ||
{ | ||
/** | ||
* Exception handler instance. | ||
* | ||
* @var callable|null | ||
*/ | ||
protected $handler; | ||
|
||
public function __construct(callable $handler = null) | ||
{ | ||
$this->handler = $handler; | ||
} | ||
|
||
/** | ||
* Set the exception handler. | ||
* | ||
* @param callable $handler | ||
* @return void | ||
*/ | ||
public function setHandler(callable $handler): void | ||
{ | ||
$this->handler = $handler; | ||
} | ||
|
||
/** | ||
* Handle an exception. | ||
* | ||
* @param Throwable $exception | ||
* @throws Throwable | ||
* @return ResponseInterface | ||
*/ | ||
public function handle(Throwable $exception): ResponseInterface | ||
{ | ||
if( empty($this->handler) ){ | ||
throw $exception; | ||
} | ||
|
||
return \call_user_func($this->handler, $exception); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace Limber\Exceptions; | ||
|
||
use Exception; | ||
|
||
class MiddlewareException extends Exception | ||
{ | ||
} |
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
Oops, something went wrong.