Fixed some templates not rendering.

This commit is contained in:
flash 2024-08-04 23:24:09 +00:00
parent 42d6c2d072
commit 2c1fa702aa
2 changed files with 19 additions and 0 deletions

View file

@ -9,6 +9,7 @@ class RoutingContext {
public function __construct(SeriaContext $context) {
$this->router = new HttpRouter(errorHandler: new RoutingErrorHandler($context));
$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 {

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