Skip to content

Commit

Permalink
use http_client() from castor
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Mar 15, 2024
1 parent f522001 commit 76d8f83
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions .castor/docker.php
Expand Up @@ -6,6 +6,7 @@
use Castor\Attribute\AsOption;
use Castor\Attribute\AsTask;
use Castor\Context;
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 @@ -15,6 +16,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 @@ -33,9 +35,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()

Check failure on line 39 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.1

Call to method request() on an unknown class Symfony\Contracts\HttpClient\HttpClientInterface.

Check failure on line 39 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.2

Call to method request() on an unknown class Symfony\Contracts\HttpClient\HttpClientInterface.

Check failure on line 39 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.3

Call to method request() on an unknown class Symfony\Contracts\HttpClient\HttpClientInterface.
->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 @@ -50,7 +54,9 @@ function about(): void
$hosts = explode('`) || Host(`', $matches['hosts']);
$urls = [...$urls, ...$hosts];
}
} catch (HttpExceptionInterface) {

Check failure on line 57 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.1

Caught class Symfony\Contracts\HttpClient\Exception\ExceptionInterface not found.

Check failure on line 57 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.2

Caught class Symfony\Contracts\HttpClient\Exception\ExceptionInterface not found.

Check failure on line 57 in .castor/docker.php

View workflow job for this annotation

GitHub Actions / Test with PHP 8.3

Caught class Symfony\Contracts\HttpClient\Exception\ExceptionInterface not found.
}

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

Expand Down

0 comments on commit 76d8f83

Please sign in to comment.