Skip to content

Commit

Permalink
Merge pull request #171 from nzkozar/http_timeout_config
Browse files Browse the repository at this point in the history
Made driver HTTP request timeouts configurable.
  • Loading branch information
stevebauman committed Jun 12, 2024
2 parents 603d75b + fc7682c commit a937130
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions config/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@

'position' => Stevebauman\Location\Position::class,

/*
|--------------------------------------------------------------------------
| HTTP Client Options
|--------------------------------------------------------------------------
|
| Here you may configure the options used by the underlying
| Laravel HTTP client. This will be used in drivers that
| request info via HTTP requests through API services.
|
*/

'http' => [
'timeout' => 3,
'connect_timeout' => 3,
],

/*
|--------------------------------------------------------------------------
| Localhost Testing
Expand Down
7 changes: 6 additions & 1 deletion src/Drivers/HttpDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ protected function http(): PendingRequest
{
$callback = static::$httpResolver ?: fn ($http) => $http;

return value($callback, Http::timeout(3)->connectTimeout(3));
return value($callback, Http::withOptions(
config('location.http', [
'timeout' => 3,
'connect_timeout' => 3
])
));
}
}

0 comments on commit a937130

Please sign in to comment.