Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use http_client() from castor #292

Merged
merged 1 commit into from Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions .castor/docker.php
Expand Up @@ -7,6 +7,7 @@
use Castor\Attribute\AsTask;
use Castor\Context;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Contracts\HttpClient\Exception\ExceptionInterface as HttpExceptionInterface;
use Symfony\Component\Process\Exception\ExceptionInterface;
use Symfony\Component\Process\ExecutableFinder;
use Symfony\Component\Process\Process;
Expand All @@ -16,6 +17,7 @@
use function Castor\context;
use function Castor\finder;
use function Castor\fs;
use function Castor\http_client;
use function Castor\io;
use function Castor\log;
use function Castor\open;
Expand All @@ -34,9 +36,11 @@ function about(): void
io()->section('Available URLs for this project:');
$urls = [variable('root_domain'), ...variable('extra_domains')];

$payload = @file_get_contents(sprintf('http://%s:8080/api/http/routers', variable('root_domain')));
if ($payload) {
$routers = json_decode($payload, true);
try {
$routers = http_client()
->request('GET', sprintf('http://%s:8080/api/http/routers', variable('root_domain')))
->toArray()
;
$projectName = variable('project_name');
foreach ($routers as $router) {
if (!preg_match("{^{$projectName}-(.*)@docker$}", $router['name'])) {
Expand All @@ -51,7 +55,9 @@ function about(): void
$hosts = explode('`) || Host(`', $matches['hosts']);
$urls = [...$urls, ...$hosts];
}
} catch (HttpExceptionInterface) {
}

io()->listing(array_map(fn ($url) => "https://{$url}", array_unique($urls)));
}

Expand Down
6 changes: 3 additions & 3 deletions castor.php
Expand Up @@ -12,10 +12,10 @@
use function docker\docker_compose_run;
use function docker\generate_certificates;
use function docker\up;
use function docker\workers_start;
use function docker\workers_stop;
// use function docker\workers_start;
// use function docker\workers_stop;

guard_min_version('0.14.0');
guard_min_version('0.15.0');

import(__DIR__ . '/.castor');

Expand Down