Skip to content

Commit

Permalink
Fix Laravel 8 compatibility
Browse files Browse the repository at this point in the history
Closes #185
  • Loading branch information
stevebauman committed Jan 17, 2025
1 parent b48fe8d commit b7caada
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/Drivers/HttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ public static function resolveHttpBy(Closure $callback): void
*/
public function process(Request $request): Fluent|false
{
return rescue(fn () => new Fluent(
$this->http()
->throw()
->acceptJson()
->get($this->url($request->getIp()))
->json()
), false, false);
return rescue(function () use ($request) {
$response = $this->http()->acceptJson()->get(
$this->url($request->getIp())
);

throw_if($response->failed());

return new Fluent($response->json());
}, false, false);
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/Drivers/MaxMind.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use PharData;
use PharFileInfo;
use RecursiveIteratorIterator;
use RuntimeException;
use Stevebauman\Location\Position;
use Stevebauman\Location\Request;

Expand All @@ -38,10 +39,15 @@ public function update(Command $command): void
$tarFileName = 'maxmind.tar.gz'
);

Http::withOptions(['sink' => $tarFilePath])->throw()->get(
$response = Http::withOptions(['sink' => $tarFilePath])->get(
$this->getDatabaseUrl()
);

throw_if(
$response->failed(),
new RuntimeException('Failed to download MaxMind database. Response: '.$response->body())
);

$archive = new PharData($tarFilePath);

$file = $this->discoverDatabaseFile($archive);
Expand Down

0 comments on commit b7caada

Please sign in to comment.