init status codes routing

This commit is contained in:
yggverse 2024-07-07 10:37:39 +03:00
parent 844374da20
commit 2b0077c5be

View file

@ -182,8 +182,12 @@ class Content
$request->getResponse() $request->getResponse()
); );
if (20 === $response->getCode()) // Process codes
switch ($response->getCode())
{ {
case 20: // ok
// Process content type
switch (true) switch (true)
{ {
case str_contains($response->getMeta(), 'text/gemini'): case str_contains($response->getMeta(), 'text/gemini'):
@ -195,12 +199,10 @@ class Content
$title $title
); );
if ($title) // detect title by document h1
{
$this->page->title->setValue( $this->page->title->setValue(
$title $title ? $title : $address->getHost(), // detect title by document h1
$response->getMeta()
); );
}
break; break;
@ -209,15 +211,37 @@ class Content
$this->data->setPlain( $this->data->setPlain(
$response->getBody() $response->getBody()
); );
}
$this->page->title->setSubtitle( $this->page->title->setValue(
$response->getMeta() $address->getHost()
); );
} }
else break;
{
case 31: // redirect @TODO
$this->data->setGemtext(
sprintf(
'=> %s',
$response->getMeta()
)
);
$this->page->title->setValue(
$address->getHost(),
sprintf(
'redirect (code %d)',
intval(
$response->getCode()
)
)
);
break;
default:
$this->page->title->setValue( $this->page->title->setValue(
'Failure', 'Failure',
sprintf( sprintf(