seria/src/RoutingContext.php

26 lines
642 B
PHP
Raw Normal View History

<?php
namespace Seria;
2024-03-30 00:38:44 +00:00
use Index\Http\Routing\{HttpRouter,IRouter,IRouteHandler};
class RoutingContext {
2024-03-30 00:38:44 +00:00
private HttpRouter $router;
2024-03-30 00:38:44 +00:00
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);
}
2024-03-30 00:38:44 +00:00
public function dispatch(): void {
$this->router->dispatch();
}
}