seria/src/RoutingContext.php
2024-03-30 00:38:44 +00:00

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();
}
}