25 lines
642 B
PHP
25 lines
642 B
PHP
<?php
|
|
namespace Seria;
|
|
|
|
use Index\Http\Routing\{HttpRouter,IRouter,IRouteHandler};
|
|
|
|
class RoutingContext {
|
|
private HttpRouter $router;
|
|
|
|
public function __construct(SeriaContext $context) {
|
|
$this->router = new HttpRouter(errorHandler: new RoutingErrorHandler($context));
|
|
$this->router->use('/', fn($resp) => $resp->setPoweredBy('Seria'));
|
|
}
|
|
|
|
public function getRouter(): IRouter {
|
|
return $this->router;
|
|
}
|
|
|
|
public function register(IRouteHandler $handler): void {
|
|
$this->router->register($handler);
|
|
}
|
|
|
|
public function dispatch(): void {
|
|
$this->router->dispatch();
|
|
}
|
|
}
|