Browse Source

implement custom route settings

main
yggverse 7 months ago
parent
commit
1c7e01f028
  1. 4
      config/example.json
  2. 16
      src/Controller/Server/Nex.php

4
config/example.json

@ -11,6 +11,10 @@
{ {
"host":"127.0.0.1", "host":"127.0.0.1",
"port":1900, "port":1900,
"route":
{
"/test":"/path/to/page.gmi"
},
"event": "event":
{ {
"init": "init":

16
src/Controller/Server/Nex.php

@ -78,7 +78,7 @@ class Nex implements MessageComponentInterface
// Route request // Route request
switch (true) switch (true)
{ {
// Item // Chanel item
case (bool) preg_match('/\/(?<id>\d+)($|\.gmi)$/i', $request, $attribute): case (bool) preg_match('/\/(?<id>\d+)($|\.gmi)$/i', $request, $attribute):
$lines = []; $lines = [];
@ -145,7 +145,7 @@ class Nex implements MessageComponentInterface
break; break;
// Chanel // Channel page
case (bool) preg_match('/^\/(?<alias>.+)$/i', $request, $attribute): case (bool) preg_match('/^\/(?<alias>.+)$/i', $request, $attribute):
$lines = []; $lines = [];
@ -207,6 +207,17 @@ class Nex implements MessageComponentInterface
// Not found // Not found
default: default:
// Try static route settings
if (isset($this->_config->route->{$request}))
{
$response = file_get_contents(
$this->_config->route->{$request}
);
}
// Build site map
else
{
$lines = []; $lines = [];
// Get channels // Get channels
@ -225,6 +236,7 @@ class Nex implements MessageComponentInterface
$lines $lines
); );
} }
}
// Debug message event on enabled // Debug message event on enabled
if ($this->_config->event->message->debug->enabled) if ($this->_config->event->message->debug->enabled)

Loading…
Cancel
Save