DomainScope middleware checks Host header per-request — Octane-safe.
Applied to Api homepage (scoped to api.lthn.io). Explorer and Docs
subdomain routes stay disabled — catch-all routes like /{section}/{page?}
match before middleware runs, breaking other routes. These modules
need own containers for proper domain isolation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Mod\Chain;
|
|
|
|
use Core\Events\ConsoleBooting;
|
|
use Core\Events\FrameworkBooted;
|
|
use Mod\Chain\Contracts\ChainDaemon;
|
|
use Mod\Chain\Contracts\ChainWallet;
|
|
use Mod\Chain\Services\DaemonRpc;
|
|
use Mod\Chain\Services\WalletRpc;
|
|
|
|
class Boot
|
|
{
|
|
public static array $listens = [
|
|
FrameworkBooted::class => 'onFrameworkBooted',
|
|
ConsoleBooting::class => 'onConsole',
|
|
];
|
|
|
|
public function onFrameworkBooted(FrameworkBooted $event): void
|
|
{
|
|
app('config')->set('chain', require __DIR__ . '/config.php');
|
|
|
|
// Bind interfaces to implementations — swap for testing/Go wrapper
|
|
app()->singleton(ChainDaemon::class, DaemonRpc::class);
|
|
app()->singleton(ChainWallet::class, WalletRpc::class);
|
|
|
|
// Keep concrete bindings for backwards compatibility
|
|
app()->singleton(DaemonRpc::class);
|
|
app()->singleton(WalletRpc::class);
|
|
|
|
app('router')->aliasMiddleware('auth.api', \App\Http\Middleware\ApiTokenAuth::class);
|
|
app('router')->aliasMiddleware('domain', \App\Http\Middleware\DomainScope::class);
|
|
}
|
|
|
|
public function onConsole(ConsoleBooting $event): void
|
|
{
|
|
$event->command(Commands\ChainStart::class);
|
|
$event->command(Commands\ChainStatus::class);
|
|
}
|
|
}
|