mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
init status codes routing
This commit is contained in:
parent
844374da20
commit
2b0077c5be
1 changed files with 60 additions and 36 deletions
|
|
@ -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(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue