@@ -5,9 +5,9 @@ |
||
| 5 | 5 | |
| 6 | 6 | class MatchFile extends BaseMatch |
| 7 | 7 | { |
| 8 | - public function __construct(public $filePath, public $contentType) |
|
| 9 | - { |
|
| 8 | + public function __construct(public $filePath, public $contentType) |
|
| 9 | + { |
|
| 10 | 10 | |
| 11 | - } |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | 13 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | protected $middlewares = array(); |
| 16 | 16 | |
| 17 | 17 | public function __construct($request){ |
| 18 | - $this->request = $request; |
|
| 18 | + $this->request = $request; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public function addMiddlewares($middlewares) { |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | public function getResponse() : HttpResponse{ |
| 27 | - $matcher = $this->resolveRequest(); |
|
| 28 | - return $this->handle($matcher); |
|
| 27 | + $matcher = $this->resolveRequest(); |
|
| 28 | + return $this->handle($matcher); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | * Returns the appropriate handler for the pending request |
| 62 | 62 | * |
| 63 | 63 | * @return AbstractHandler $handler |
| 64 | - */ |
|
| 64 | + */ |
|
| 65 | 65 | public static function getHandler(): AbstractHandler |
| 66 | 66 | { |
| 67 | 67 | $regex = '/\.(?:'.implode('|', static::$_config->static_files_extensions).')$/'; |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Lepton\Http\Response; |
| 4 | 4 | |
| 5 | - class SuccessResponse extends HttpResponse |
|
| 5 | + class SuccessResponse extends HttpResponse |
|
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | public function __construct( |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Lepton\Http\Response; |
| 4 | 4 | |
| 5 | - class FileResponse extends SuccessResponse |
|
| 5 | + class FileResponse extends SuccessResponse |
|
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | public function __construct( |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Lepton\Http\Response; |
| 4 | 4 | |
| 5 | - class NotFoundResponse extends HttpResponse |
|
| 5 | + class NotFoundResponse extends HttpResponse |
|
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | public function __construct( |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Lepton\Http\Response; |
| 4 | 4 | |
| 5 | - class InternalErrorResponse extends HttpResponse |
|
| 5 | + class InternalErrorResponse extends HttpResponse |
|
| 6 | 6 | { |
| 7 | 7 | |
| 8 | 8 | public function __construct( |
@@ -58,13 +58,13 @@ |
||
| 58 | 58 | if($matcher instanceof MatchRoute) { |
| 59 | 59 | |
| 60 | 60 | foreach($this->middlewares as $middleware => $args){ |
| 61 | - $middlewareInstance = new $middleware(); |
|
| 62 | - $middlewareInstance->addMatcher($matcher); |
|
| 63 | - $middlewareInstance->setRequest($this->request); |
|
| 64 | - $middlewareResult = $middlewareInstance(...$args); |
|
| 65 | - if($middlewareResult instanceof HttpResponse){ |
|
| 61 | + $middlewareInstance = new $middleware(); |
|
| 62 | + $middlewareInstance->addMatcher($matcher); |
|
| 63 | + $middlewareInstance->setRequest($this->request); |
|
| 64 | + $middlewareResult = $middlewareInstance(...$args); |
|
| 65 | + if($middlewareResult instanceof HttpResponse){ |
|
| 66 | 66 | return $middlewareResult; |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | Application::$controller = $matcher->controller; |
@@ -52,14 +52,14 @@ |
||
| 52 | 52 | return new MatchFile(filePath: $filePath, contentType: $contentType); |
| 53 | 53 | } else { |
| 54 | 54 | die($filePath); |
| 55 | - return new Match404(); |
|
| 55 | + return new Match404(); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function handle($match): FileResponse|NotFoundResponse{ |
| 60 | - if($match instanceof Match404){ |
|
| 60 | + if($match instanceof Match404){ |
|
| 61 | 61 | return new NotFoundResponse(); |
| 62 | - } |
|
| 63 | - return new FileResponse($match->filePath, $match->contentType); |
|
| 62 | + } |
|
| 63 | + return new FileResponse($match->filePath, $match->contentType); |
|
| 64 | 64 | } |
| 65 | 65 | } |