Fixed some templates not rendering.
This commit is contained in:
parent
42d6c2d072
commit
2c1fa702aa
2 changed files with 19 additions and 0 deletions
|
@ -9,6 +9,7 @@ class RoutingContext {
|
||||||
public function __construct(SeriaContext $context) {
|
public function __construct(SeriaContext $context) {
|
||||||
$this->router = new HttpRouter(errorHandler: new RoutingErrorHandler($context));
|
$this->router = new HttpRouter(errorHandler: new RoutingErrorHandler($context));
|
||||||
$this->router->use('/', fn($resp) => $resp->setPoweredBy('Seria'));
|
$this->router->use('/', fn($resp) => $resp->setPoweredBy('Seria'));
|
||||||
|
$this->router->registerContentHandler(new StringableContentHandler); // this should really be in Index lol but i can't be bothered rn!
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRouter(): IRouter {
|
public function getRouter(): IRouter {
|
||||||
|
|
18
src/StringableContentHandler.php
Normal file
18
src/StringableContentHandler.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
namespace Seria;
|
||||||
|
|
||||||
|
use Stringable;
|
||||||
|
use Index\Http\HttpResponseBuilder;
|
||||||
|
use Index\Http\Content\StringContent;
|
||||||
|
use Index\Http\ContentHandling\IContentHandler;
|
||||||
|
|
||||||
|
class StringableContentHandler implements IContentHandler {
|
||||||
|
public function match(mixed $content): bool {
|
||||||
|
return $content instanceof Stringable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param Stringable $content */
|
||||||
|
public function handle(HttpResponseBuilder $response, mixed $content): void {
|
||||||
|
$response->setContent(new StringContent((string)$content));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue